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:
chochos
2010-11-29 19:27:25 +00:00
parent 2a7d4063e2
commit b1e09634d6
7 changed files with 87 additions and 56 deletions
@@ -88,29 +88,33 @@ public class FieldParseInfo {
throw new ParseException(String.format("Insufficient data for LLVAR field, pos %d", pos), pos);
}
if (custom == null) {
return new IsoValue<String>(type, new String(buf, pos + 2, length), null);
return new IsoValue<String>(type, new String(buf, pos + 2, length), length, null);
} else {
IsoValue<T> v = new IsoValue<T>(type, custom.decodeField(new String(buf, pos + 2, length)), custom);
IsoValue<T> v = new IsoValue<T>(type, custom.decodeField(new String(buf, pos + 2, length)), length, custom);
if (v.getValue() == null) {
return new IsoValue<String>(type, new String(buf, pos + 2, length), null);
return new IsoValue<String>(type, new String(buf, pos + 2, length), length, null);
}
return v;
}
} else if (type == IsoType.LLLVAR) {
if (!(Character.isDigit(buf[pos]) && Character.isDigit(buf[pos+1]) && Character.isDigit(buf[pos+2]))) {
throw new ParseException(String.format("Invalid LLLVAR length '%s' pos %d", new String(buf, pos, 3), pos), pos);
}
length = ((buf[pos] - 48) * 100) + ((buf[pos + 1] - 48) * 10) + (buf[pos + 2] - 48);
if (length < 0) {
throw new ParseException(String.format("Invalid LLLVAR length %d pos %d", length, pos), pos);
}
if (pos+3 > buf.length || length+pos+3 > buf.length) {
if (length+pos+3 > buf.length) {
throw new ParseException(String.format("Insufficient data for LLLVAR field, pos %d", pos), pos);
}
String _v = length == 0 ? "" : new String(buf, pos + 3, length);
if (custom == null) {
return new IsoValue<String>(type, new String(buf, pos + 3, length), null);
return new IsoValue<String>(type, _v, length, null);
} else {
IsoValue<T> v = new IsoValue<T>(type, custom.decodeField(new String(buf, pos + 3, length)), custom);
IsoValue<T> v = new IsoValue<T>(type, custom.decodeField(_v), length, custom);
if (v.getValue() == null) {
//problems decoding? return the string
return new IsoValue<String>(type, new String(buf, pos + 3, length), null);
return new IsoValue<String>(type, _v, length, null);
}
return v;
}