Commit d8f033e6 authored by garciay's avatar garciay

Remove duplicate org.etsi.ttcn.common.ByteHelper.java file and replace it by...

Remove duplicate org.etsi.ttcn.common.ByteHelper.java file and replace it by org.etsi.common.ByteHelper.java after merge
parent 739f1ca2
......@@ -84,7 +84,7 @@ public class Management implements IManagementTA, IManagementLayers {
/**
* ITS-AID for Secure other profile
*/
private static final String TsItsAidOther = ((CharstringValue)TERFactory.getInstance().getTaParameter("TsItsAidOther")).getString();
private static final String TsItsAidOther = "141"; // GN-MGMT ((CharstringValue)TERFactory.getInstance().getTaParameter("TsItsAidOther")).getString();
/**
* Link-layer address of Component
......
......@@ -51,7 +51,7 @@ public class PcapMultiplexer implements Runnable {
int r = Pcap.findAllDevs(alldevs, errbuf);
if (r == Pcap.NOT_OK || alldevs.isEmpty()) {
if (r != Pcap.OK || alldevs.isEmpty()) {
TERFactory.getInstance().logError("Can't read list of devices, error is %s" + errbuf.toString());
return;
}
......
......@@ -115,7 +115,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
// UDP socket for communication with UT
running = true;
try {
utSocket = new DatagramSocket();
utSocket = new DatagramSocket(/*utPeerPort*/);
utThread = new UdpThread(utSocket);
utThread.start();
} catch (Exception e) {
......@@ -125,8 +125,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
@Override
public boolean send(final byte[] message) {
if (_offlineMode.equals("true")) {
/* FIXME: For debug only. Uncomment if no UT*/
if (/*true or */_offlineMode.equals("true")) { /* FIXME: For debug only. Uncomment if no UT - Do not forget the return true below*/
try {
Thread.sleep(500);
} catch (InterruptedException e) {
......@@ -202,7 +201,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
}
notifyObservers(new PortEvent(rsp, getPortName(), getComponentName()));
}
/* if(true)
/* FIXME: For debug only if(true)
return true;
*/
try {
......@@ -283,8 +282,8 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
notifyObservers(new PortEvent(payload, getPortName(), getComponentName()));
} // else, packet was dropped
} else { // Notify received payload
setChanged();
notifyObservers(new PortEvent(ByteHelper.extract(packet.getData(), packet.getOffset(), packet.getLength()), getPortName(), getComponentName()));
setChanged();
notifyObservers(new PortEvent(ByteHelper.extract(packet.getData(), packet.getOffset(), packet.getLength()), getPortName(), getComponentName()));
}
} catch (IOException e) {
running = false;
......
......@@ -9,7 +9,7 @@ import java.util.Map;
import java.util.TreeMap;
import org.etsi.adapter.TERFactory;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class CodecBuffer {
......
......@@ -82,7 +82,8 @@ public class CodecFactory {
codec = externalCodecs.get(encoding);
if(codec != null) {
//TERFactory.getInstance().logDebug(String.format("%50s", encoding));
//TERFactory.getInstance().logDebug(" ==> " + codec.getClass().getName());
//TERFactory.getInstance().logDebug(" ==> " + codec.getClass().getName());
System.out.println(String.format("%50s", encoding) + " ==> " + codec.getClass().getName());
return codec;
}
return null;
......@@ -91,10 +92,12 @@ public class CodecFactory {
public ICodec getCodec(MainCodec mainCodec, int classType, String encoding, String typeName) {
//TERFactory.getInstance().logDebug(String.format("%50s", typeName + "(" + encoding + ")"));
System.out.println(String.format("%50s", typeName + "(" + encoding + ")"));
Class<? extends ICodec> cls = null;
Class<?>[] ctorParams = {MainCodec.class};
//TERFactory.getInstance().logDebug("getCodec: Search internal codec for " + classType + '/' + encoding + '/' + typeName);
System.out.println("getCodec: Search internal codec for " + classType + '/' + encoding + '/' + typeName);
cls = codecs.get(classType + '/' + encoding + '/' + typeName);
if(cls == null) {
cls = codecs.get(classType + '/' + encoding + '/');
......@@ -105,6 +108,7 @@ public class CodecFactory {
if(cls != null) {
//TERFactory.getInstance().logDebug(" ==> " + cls.getName());
System.out.println(" ==> " + cls.getName());
try {
Constructor<? extends ICodec> ctor = cls.getConstructor(ctorParams);
return ctor.newInstance(mainCodec);
......@@ -114,7 +118,8 @@ public class CodecFactory {
}
}
//TERFactory.getInstance().logDebug(" ==> No codec found !");
//TERFactory.getInstance().logDebug(" ==> No codec found !");
System.out.println(" ==> No codec found !");
return new Dummy(mainCodec);
}
......
......@@ -22,14 +22,10 @@ public class MainCodec extends ICodec {
}
public Value triDecode(TriMessage message, Type decodingHypothesis) {
// TERFactory.getInstance().logDebug("############################################################################################");
return decode(new CodecBuffer(message.getEncodedMessage()), decodingHypothesis);
}
public TriMessage triEncode(Value value) {
// TERFactory.getInstance().logDebug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
CodecBuffer encoded = encode(value);
encoded.runCallbacks();
return new TriMessageImpl(encoded.getBytes());
......
......@@ -8,7 +8,7 @@ package org.etsi.ttcn.codec.generic;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
import org.etsi.ttcn.tci.EnumeratedValue;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.codec.ICodec;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
......
......@@ -8,7 +8,7 @@ package org.etsi.ttcn.codec.generic;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.ICodec;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.FloatValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
......
......@@ -12,7 +12,7 @@ import java.util.regex.Pattern;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
import org.etsi.ttcn.tci.IntegerValue;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.codec.ICodec;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
......
......@@ -7,7 +7,7 @@ import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.IMarkerCallback;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class AnyIcmpv6Message extends Record implements IMarkerCallback {
......
......@@ -7,7 +7,7 @@ import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class Ipv6ExtHdr extends Record {
......
......@@ -5,7 +5,7 @@ import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.IMarkerCallback;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class Ipv6Header extends Record implements IMarkerCallback {
......
......@@ -8,7 +8,7 @@ package org.etsi.ttcn.codec.its.adapter;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.UnionValue;
public class AcFsapPrimitive extends Union {
......
......@@ -10,7 +10,7 @@ import org.etsi.ttcn.tci.UnionValue;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class AcGnPrimitive extends Union {
......
......@@ -11,7 +11,7 @@ import org.etsi.ttcn.tci.UnionValue;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class AcGnResponse extends Union {
......
......@@ -5,7 +5,7 @@ import org.etsi.ttcn.tci.UnionValue;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class AcGnssPrimitive extends Union {
......
......@@ -3,7 +3,7 @@ package org.etsi.ttcn.codec.its.adapter;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.UnionValue;
......
......@@ -10,7 +10,7 @@ import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.IMarkerCallback;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.EnumeratedValue;
import org.etsi.ttcn.tci.IntegerValue;
import org.etsi.ttcn.tci.RecordValue;
......
......@@ -8,7 +8,7 @@ package org.etsi.ttcn.codec.its.geonetworking;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.OctetstringValue;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
......
......@@ -8,7 +8,7 @@ package org.etsi.ttcn.codec.its.geonetworking;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
......
......@@ -8,7 +8,7 @@ package org.etsi.ttcn.codec.its.security;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
......
......@@ -16,14 +16,8 @@ public class ItsAidSsp extends Record {
public ItsAidSsp(MainCodec mainCodec) {
super(mainCodec);
// setLengths();
}
// private void setLengths() {
// mainCodec.setHint("Bit2Len", "2");
// mainCodec.setHint("Bit3Len", "3");
// }
//
@Override
protected void postEncodeField(String fieldName, CodecBuffer buf) {
// TERFactory.getInstance().logDebug(">>> ItsAidSsp.postEncodeField: " + fieldName);
......@@ -41,11 +35,15 @@ public class ItsAidSsp extends Record {
// TERFactory.getInstance().logDebug(">>> ItsAidSsp.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
if (fieldName.equals("service_specific_permissions")) {
int len = buf.readBits(Byte.SIZE)[0]; // FIXME It depends of the len value : <= 127 or > 127
// FIXME Check for opaque<var> length encoding
//int len = ByteHelper.byteArrayToInt(buf.readBits(Integer.SIZE)); // field_sizeLen is 1 bytes
// TERFactory.getInstance().logDebug("ItsAidSsp.preDecodeField: len = " + len);
mainCodec.setHint("Oct1to31Len", Integer.toString(len));
int len = buf.readBits(Byte.SIZE)[0]; // FIXME Should be IntX?
// TERFactory.getInstance().logDebug("ItsAidSsp.preDecodeField: len=" + len);
if (mainCodec.getHint("ServiceSpecificPermissionsContainer").equals("sspCAM")) {
mainCodec.setHint("SspCAMLen", Integer.toString(len - 1/* Version byte*/));
} else if (mainCodec.getHint("ServiceSpecificPermissionsContainer").equals("sspDENM")) {
mainCodec.setHint("SspDENMLen", Integer.toString(len -1/* Version byte*/));
} else {
mainCodec.setHint("ServiceSpecificPermissionsContainer.opaqueLen", Integer.toString(len - 1/* Version byte*/));
}
}
}
......@@ -60,6 +58,21 @@ public class ItsAidSsp extends Record {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "sspCAM");
} else if (itsaid == 37) {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "sspDENM");
} else if (itsaid == 138) {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "opaque");
//mainCodec.setHint("ServiceSpecificPermissionsContainer", "sspMAPEM");
} else if (itsaid == 137) {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "opaque");
//mainCodec.setHint("ServiceSpecificPermissionsContainer", "sspSPATEM");
} else if (itsaid == 139) {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "opaque");
//mainCodec.setHint("ServiceSpecificPermissionsContainer", "sspIVIM");
} else if (itsaid == 140) {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "opaque");
//mainCodec.setHint("ServiceSpecificPermissionsContainer", "sspSxEM");
} else if (itsaid == 141) {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "opaque");
//mainCodec.setHint("ServiceSpecificPermissionsContainer", "sspGnMgmt");
} else {
mainCodec.setHint("ServiceSpecificPermissionsContainer", "opaque");
}
......
......@@ -8,7 +8,7 @@ package org.etsi.ttcn.codec.its.security;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
......@@ -33,20 +33,8 @@ public class ServiceSpecificPermissions extends Record {
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
// TERFactory.getInstance().logDebug(">>> ServiceSpecificPermissions.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
if (fieldName.equals("version")) {
byte version = buf.getBytes(0, 1)[0];
switch (version) {
case (byte)0x01:
mainCodec.setHint("version", String.valueOf(version));
break;
} // End of 'switch' statement
} else if (fieldName.equals("sspContainer")) {
if (mainCodec.getHint("version") != null) {
mainCodec.setPresenceHint(fieldName, true);
} else {
mainCodec.setPresenceHint(fieldName, false);
}
if (fieldName.equals("sspContainer")) {
mainCodec.setPresenceHint(fieldName, true);
}
}
......
......@@ -3,7 +3,7 @@ package org.etsi.ttcn.codec.its.security;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
......
......@@ -3,7 +3,7 @@ package org.etsi.ttcn.codec.its.security;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
......
......@@ -6,7 +6,7 @@
package org.etsi.ttcn.codec.its.security;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
public class TlsHelper {
......
......@@ -9,7 +9,7 @@ import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.IMarkerCallback;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.Value;
public class UtPayload extends Record implements IMarkerCallback {
......
/**
* @author ETSI / STF462
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.common;
import java.nio.ByteBuffer;
import org.etsi.adapter.TERFactory;
/* FIXME: to be merged with org.etsi.common.ByteHelper */
public class ByteHelper {
public static byte[] intToByteArray(final int value, final int length) {
byte[] b = new byte[length];
for (int i = length - 1; i >= 0; i--) {
int offset = (b.length - 1 - i) * 8;
b[i] = (byte) ((value >>> offset) & 0xFF);
}
return b;
}
public static byte[] longToByteArray(final long value, final int length) {
byte[] b = new byte[length];
for (int i = length - 1; i >= 0; i--) {
int offset = (b.length - 1 - i) * 8;
b[i] = (byte) ((value >>> offset) & 0xFF);
}
return b;
}
public static byte[] floatToByteArray(final float value) {
return ByteBuffer.allocate(Float.SIZE / Byte.SIZE).putFloat(value).array();
}
/** Convert a byte array into an integer assuming that the first byte is the most significant
*
* @param b The byte array to convert
* @return The integer value
*/
public static Integer byteArrayToInt(final byte[] b) {
// Sanity check
if ((b == null) || ((b.length * Byte.SIZE) > Integer.SIZE)) {
return Integer.MAX_VALUE;
}
int value = 0;
for (int i = 0; i < b.length; i++) {
value = (value << 8) + (b[i] & 0xff);
}
return new Integer(value);
} // End of method byteArrayToInt
/** Convert a byte array into a signed integer assuming that padding bits are in first byte
*
* @param b The byte array to convert
* @param significantBits number of significant bits in the array
* @return The integer value
*/
public static int byteArrayToSignedInt(final byte[] b, final int significantBits) {
int value = 0;
for (int i = 0; i < b.length; i++) {
value = (value << 8) + (b[i] & 0xff);
}
int shift = 32 - significantBits;
// Restore sign bit by shifting left and right
if(shift > 0) {
value <<= shift;
value >>= shift;
}
return new Integer(value);
}
/** Convert a byte array into a Long assuming that the first byte is the most significant
*
* @param b The byte array to convert
* @return The Long value
*/
public static Long byteArrayToLong(final byte[] b) {
// Sanity check
if ((b == null) || ((b.length * Byte.SIZE) > Long.SIZE)) {
return Long.MAX_VALUE;
}
long value = 0;
for (int i = 0; i < b.length; i++) {
value = (value << 8) + (b[i] & 0xff);
}
return new Long(value);
} // End of method byteArrayToLong
public static Float byteArrayToFloat(final byte[] b) {
return ByteBuffer.wrap(b).getFloat();
}
public static byte[] hexStringToByteArray(final String s) {
String str = "";
for(String ss : s.split("[^0-9A-Fa-f]")) {
str = str + ss;
}
int len = str.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(str.charAt(i), 16) << 4)
+ Character.digit(str.charAt(i+1), 16));
}
return data;
}
public static byte[] concat(byte[]... arrays) {
int length = 0;
for (byte[] array : arrays) {
if(array != null) {
length += array.length;
}
}
byte[] result = new byte[length];
int position = 0;
for (byte[] array : arrays) {
if(array != null) {
System.arraycopy(array, 0, result, position, array.length);
position += array.length;
}
}
return result;
}
/** Extract a sub part of a byte array
* @param array The original array
* @param offset The offset to start the extract operation
* @param length The number of bytes to extract
* @return The sub part of a provided byte array
*/
public static byte[] extract(byte[] array, int offset, int length) {
// Sanity check
if ((array == null) || (offset > array.length)) {
return null;
}
byte[] result = new byte[length];
System.arraycopy(array, offset, result, 0, length);
return result;
}
public static byte[] fill(final byte[] buffer, final int length, final byte pattern) {
byte[] result = new byte[length];
if (buffer == null) { // Fill it
for(int i = 0; i < length; ++i) {
result[i] = pattern;
} // End of 'for' statement
} else { //
for(int i = 0; i < length - buffer.length; ++i) {
result[length - i - 1] = pattern;
} // End of 'for' statement
System.arraycopy(buffer, 0, result, 0, buffer.length);
}
return result;
}
/**
* Dump a byte array in hex/ascii mode.
* @param label The dump label
* @param buffer The byte array to dump
*/
public synchronized static void dump(final String label, final byte[] buffer)
{
if ((buffer != null) && (buffer.length != 0))
{
TERFactory.getInstance().logDebug(label);
StringBuilder finalHexLine = new StringBuilder();
StringBuilder finalCharLine = new StringBuilder();
int nCounter = 0;
int nOffset = 0;
// Flush header.
TERFactory.getInstance().logDebug(" HEX | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F : 0 1 2 3 4 5 6 7 8 9 A B C D E F ");
TERFactory.getInstance().logDebug("-----|+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-:--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
for (int i = 0; i < buffer.length; ++i)
{
byte c = (byte)buffer[i];
String fmtHex = String.format("%02x ", c);
String fmtChar = String.format("%c ", Character.isISOControl((char)c) || c < 0 ? '.' : (char)c);
if (nOffset % 16 == 0)
{
finalHexLine.append(String.format("%05x| ", nOffset));
}
finalHexLine.append(fmtHex);
finalCharLine.append(fmtChar);
if (nCounter == 15)
{
// Flush line.
TERFactory.getInstance().logDebug(String.format("%s : %s", finalHexLine.toString(), finalCharLine.toString()));
// Reset buffer.
finalHexLine.delete(0, finalHexLine.length());
finalCharLine.delete(0, finalCharLine.length());
nCounter = 0;
}
else
{
nCounter++;
}
nOffset++;
}
if (nCounter < 16)
{
// Pad till 15.
for (int i = nCounter; i < 16; i++)
{
finalHexLine.append(" ");
finalCharLine.append(" ");
}
// Flush line.
TERFactory.getInstance().logDebug(String.format("%s : %s", finalHexLine.toString(), finalCharLine.toString()));
}
}
}
}
......@@ -286,14 +286,14 @@ public class ByteHelper {
{
if ((buffer != null) && (buffer.length != 0))
{
TERFactory.getInstance().logDebug(label);
//TERFactory.getInstance().logDebug(label);
StringBuilder finalHexLine = new StringBuilder();
StringBuilder finalCharLine = new StringBuilder();
int nCounter = 0;
int nOffset = 0;
// Flush header.
TERFactory.getInstance().logDebug(" HEX | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F : 0 1 2 3 4 5 6 7 8 9 A B C D E F ");
TERFactory.getInstance().logDebug("-----|+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-:--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
//TERFactory.getInstance().logDebug(" HEX | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F : 0 1 2 3 4 5 6 7 8 9 A B C D E F ");
//TERFactory.getInstance().logDebug("-----|+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-:--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
for (int i = 0; i < buffer.length; ++i)
{
byte c = (byte)buffer[i];
......@@ -311,7 +311,7 @@ public class ByteHelper {
if (nCounter == 15)
{
// Flush line.
TERFactory.getInstance().logDebug(String.format("%s : %s", finalHexLine.toString(), finalCharLine.toString()));
//TERFactory.getInstance().logDebug(String.format("%s : %s", finalHexLine.toString(), finalCharLine.toString()));
// Reset buffer.
finalHexLine.delete(0, finalHexLine.length());
finalCharLine.delete(0, finalCharLine.length());
......@@ -333,7 +333,7 @@ public class ByteHelper {
finalCharLine.append(" ");
}
// Flush line.
TERFactory.getInstance().logDebug(String.format("%s : %s", finalHexLine.toString(), finalCharLine.toString()));
//TERFactory.getInstance().logDebug(String.format("%s : %s", finalHexLine.toString(), finalCharLine.toString()));
}
}
}
......
<
......@@ -33,7 +33,7 @@ public class Its_CodecProvider implements TciCDProvided, ChannelEventHandler, IT
private CodecFactory _cf;
public Its_CodecProvider() {
_logger.entering("Its_CodecProvider", "Its_CodecProvider");
//_logger.entering("Its_CodecProvider", "Its_CodecProvider");
// Load Codec settings
_cdReq = null;
......@@ -56,9 +56,9 @@ public class Its_CodecProvider implements TciCDProvided, ChannelEventHandler, IT
//TERFactory.getInstance().logError("Unsupported logging level: " + debugLevel);
level = Level.OFF;
}
_logger.addHandler(new ConsoleHandler());
_logger.setLevel(level);
_logger.getHandlers()[0].setLevel(level);
//_logger.addHandler(new ConsoleHandler());