Consider CustomBinaryField codec for LLBIN/LLLBIN ref #9
This commit is contained in:
@@ -83,8 +83,9 @@ public class IsoValue<T> implements Cloneable {
|
||||
} else {
|
||||
length = value.toString().length() / 2 + (value.toString().length() % 2);
|
||||
}
|
||||
} else if (custom instanceof CustomBinaryField) {
|
||||
length = ((CustomBinaryField<T>)custom).encodeBinaryField(value).length;
|
||||
} else {
|
||||
//TODO special encoder, NO strings
|
||||
String enc = custom.encodeField(value);
|
||||
if (enc == null) {
|
||||
enc = value == null ? "" : value.toString();
|
||||
@@ -130,7 +131,13 @@ public class IsoValue<T> implements Cloneable {
|
||||
}
|
||||
} else if (t == IsoType.LLBIN || t == IsoType.LLLBIN) {
|
||||
if (len == 0) {
|
||||
//TODO customfield binary!
|
||||
if (custom == null) {
|
||||
length = ((byte[])val).length;
|
||||
} else if (custom instanceof CustomBinaryField) {
|
||||
length = ((CustomBinaryField<T>)custom).encodeBinaryField(value).length;
|
||||
} else {
|
||||
length = custom.encodeField(value).length();
|
||||
}
|
||||
length = custom == null ? ((byte[])val).length : custom.encodeField(value).length();
|
||||
}
|
||||
if (t == IsoType.LLBIN && length > 99) {
|
||||
@@ -302,6 +309,10 @@ public class IsoValue<T> implements Cloneable {
|
||||
if (value instanceof byte[]) {
|
||||
outs.write((byte[])value);
|
||||
missing = length - ((byte[])value).length;
|
||||
} else if (encoder instanceof CustomBinaryField) {
|
||||
byte[] binval = ((CustomBinaryField<T>) encoder).encodeBinaryField(value);
|
||||
outs.write(binval);
|
||||
missing = length - binval.length;
|
||||
} else {
|
||||
byte[] binval = HexCodec.hexDecode(value.toString());
|
||||
outs.write(binval);
|
||||
|
||||
Reference in New Issue
Block a user