Made several changes that result in considerable performance improvements:
- Fields inside the IsoMessage are now stored in an IsoValue[] instead of a map (this avoids the sorting step when encoding) - The constructor IsoValue(IsoType, T, int, CustomField) for LLVAR and LLLVAR types uses the received length parameter instead of reencoding the value with the CustomField; this results in much faster parsing performance. - FieldParseInfo passes the length of LLVAR and LLLVAR fields to the IsoValue constructor so that reencoding the value (or getting the length of the string) is not necessary. Field header length is checked to be digits when parsing ASCII. - IsoType now parses AMOUNT values as BigDecimals. - MessageFactory has separate code for parsing binary and ASCII messages. Also, the DTD was moved to the resources directory. git-svn-id: https://j8583.svn.sourceforge.net/svnroot/j8583/j8583@56 db60a039-f72e-0410-b1d2-baa000846441
This commit is contained in:
@@ -96,7 +96,9 @@ public class IsoValue<T> implements Cloneable {
|
||||
if (length == 0 && t.needsLength()) {
|
||||
throw new IllegalArgumentException(String.format("Length must be greater than zero for type %s (value '%s')", t, val));
|
||||
} else if (t == IsoType.LLVAR || t == IsoType.LLLVAR) {
|
||||
length = custom == null ? val.toString().length() : custom.encodeField(value).length();
|
||||
if (len == 0) {
|
||||
length = custom == null ? val.toString().length() : custom.encodeField(value).length();
|
||||
}
|
||||
if (t == IsoType.LLVAR && length > 99) {
|
||||
throw new IllegalArgumentException("LLVAR can only hold values up to 99 chars");
|
||||
} else if (t == IsoType.LLLVAR && length > 999) {
|
||||
@@ -130,7 +132,11 @@ public class IsoValue<T> implements Cloneable {
|
||||
}
|
||||
if (type == IsoType.NUMERIC || type == IsoType.AMOUNT) {
|
||||
if (type == IsoType.AMOUNT) {
|
||||
return type.format((BigDecimal)value, 12);
|
||||
if (value instanceof BigDecimal) {
|
||||
return type.format((BigDecimal)value, 12);
|
||||
} else {
|
||||
return type.format(value.toString(), 12);
|
||||
}
|
||||
} else if (value instanceof Number) {
|
||||
return type.format(((Number)value).longValue(), length);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user