Fix #10 - improve use of type parameters instead of suppressing warnings
This commit is contained in:
@@ -35,8 +35,9 @@ public abstract class AlphaNumericFieldParseInfo extends FieldParseInfo {
|
||||
super(t, len);
|
||||
}
|
||||
|
||||
public IsoValue<?> parse(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<?> custom)
|
||||
@Override
|
||||
public <T> IsoValue<?> parse(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid ALPHA/NUM field %d position %d",
|
||||
@@ -53,12 +54,9 @@ public abstract class AlphaNumericFieldParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<String>(type, _v, length, null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(_v), length, custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<String>(type, _v, length, null);
|
||||
}
|
||||
return v;
|
||||
T decoded = custom.decodeField(_v);
|
||||
return decoded == null ? new IsoValue<String>(type, _v, length, null) :
|
||||
new IsoValue<T>(type, decoded, length, custom);
|
||||
}
|
||||
} catch (StringIndexOutOfBoundsException ex) {
|
||||
throw new ParseException(String.format(
|
||||
|
||||
@@ -35,8 +35,9 @@ public class AlphaParseInfo extends AlphaNumericFieldParseInfo {
|
||||
super(IsoType.ALPHA, len);
|
||||
}
|
||||
|
||||
public IsoValue<?> parseBinary(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<?> custom)
|
||||
@Override
|
||||
public <T> IsoValue<?> parseBinary(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid bin ALPHA field %d position %d",
|
||||
@@ -50,12 +51,10 @@ public class AlphaParseInfo extends AlphaNumericFieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<String>(type, new String(buf, pos, length, getCharacterEncoding()), length, null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(new String(buf, pos, length, getCharacterEncoding())), length, custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<String>(type, new String(buf, pos, length, getCharacterEncoding()), length, null);
|
||||
}
|
||||
return v;
|
||||
T decoded = custom.decodeField(new String(buf, pos, length, getCharacterEncoding()));
|
||||
return decoded == null ?
|
||||
new IsoValue<String>(type, new String(buf, pos, length, getCharacterEncoding()), length, null) :
|
||||
new IsoValue<T>(type, decoded, length, custom);
|
||||
}
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
throw new ParseException(String.format(
|
||||
|
||||
@@ -37,8 +37,9 @@ public class AmountParseInfo extends FieldParseInfo {
|
||||
super(IsoType.AMOUNT, 12);
|
||||
}
|
||||
|
||||
public IsoValue<BigDecimal> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
@Override
|
||||
public <T> IsoValue<BigDecimal> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid AMOUNT field %d position %d",
|
||||
@@ -50,7 +51,7 @@ public class AmountParseInfo extends FieldParseInfo {
|
||||
}
|
||||
String c = new String(buf, pos, 12, getCharacterEncoding());
|
||||
try {
|
||||
return new IsoValue<BigDecimal>(type, new BigDecimal(c).movePointLeft(2), null);
|
||||
return new IsoValue<BigDecimal>(type, new BigDecimal(c).movePointLeft(2));
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new ParseException(String.format("Cannot read amount '%s' field %d pos %d",
|
||||
c, field, pos), pos);
|
||||
@@ -60,8 +61,9 @@ public class AmountParseInfo extends FieldParseInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public IsoValue<BigDecimal> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
@Override
|
||||
public <T> IsoValue<BigDecimal> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
char[] digits = new char[13];
|
||||
digits[10] = '.';
|
||||
@@ -74,7 +76,7 @@ public class AmountParseInfo extends FieldParseInfo {
|
||||
}
|
||||
}
|
||||
try {
|
||||
return new IsoValue<BigDecimal>(IsoType.AMOUNT, new BigDecimal(new String(digits)), null);
|
||||
return new IsoValue<BigDecimal>(IsoType.AMOUNT, new BigDecimal(new String(digits)));
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new ParseException(String.format("Cannot read amount '%s' field %d pos %d",
|
||||
new String(digits), field, pos), pos);
|
||||
|
||||
@@ -38,8 +38,8 @@ public class BinaryParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<?> parse(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<?> custom)
|
||||
public <T> IsoValue<?> parse(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid BINARY field %d position %d",
|
||||
@@ -54,18 +54,15 @@ public class BinaryParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<byte[]>(type, binval, binval.length, null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(new String(buf, pos, length*2, getCharacterEncoding())), length, custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<byte[]>(type, binval, binval.length, null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(new String(buf, pos, length*2, getCharacterEncoding()));
|
||||
return dec == null ? new IsoValue<byte[]>(type, binval, binval.length, null) :
|
||||
new IsoValue<T>(type, dec, length, custom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<?> parseBinary(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<?> custom) throws ParseException {
|
||||
public <T> IsoValue<?> parseBinary(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<T> custom) throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid BINARY field %d position %d",
|
||||
field, pos), pos);
|
||||
@@ -80,12 +77,9 @@ public class BinaryParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<byte[]>(type, _v, length, null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(HexCodec.hexEncode(_v, 0, _v.length)), length, custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<byte[]>(type, _v, length, null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(HexCodec.hexEncode(_v, 0, _v.length));
|
||||
return dec == null ? new IsoValue<byte[]>(type, _v, length, null) :
|
||||
new IsoValue<T>(type, dec, length, custom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,8 @@ public class ConfigParser {
|
||||
throw new IOException("Invalid ISO8583 type for template: " + elem.getAttribute("type"));
|
||||
}
|
||||
NodeList fields = elem.getElementsByTagName("field");
|
||||
IsoMessage m = new IsoMessage();
|
||||
@SuppressWarnings("unchecked")
|
||||
T m = (T)new IsoMessage();
|
||||
m.setType(type);
|
||||
m.setCharacterEncoding(mfact.getCharacterEncoding());
|
||||
for (int j = 0; j < fields.getLength(); j++) {
|
||||
@@ -184,7 +185,7 @@ public class ConfigParser {
|
||||
CustomField<Object> _cf = mfact.getCustomField(num);
|
||||
m.setValue(num, _cf == null ? v : _cf.decodeField(v), _cf, itype, length);
|
||||
}
|
||||
mfact.addMessageTemplate((T)m);
|
||||
mfact.addMessageTemplate(m);
|
||||
}
|
||||
|
||||
//Read the parsing guides
|
||||
|
||||
@@ -42,8 +42,8 @@ public class Date10ParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<Date> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid DATE10 field %d position %d",
|
||||
@@ -68,8 +68,8 @@ public class Date10ParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<Date> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid DATE10 field %d position %d",
|
||||
|
||||
@@ -37,8 +37,8 @@ public class Date4ParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parse(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<?> custom) throws ParseException {
|
||||
public <T> IsoValue<Date> parse(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<T> custom) throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid DATE4 field %d position %d",
|
||||
field, pos), pos);
|
||||
@@ -60,8 +60,8 @@ public class Date4ParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parseBinary(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<?> custom) throws ParseException {
|
||||
public <T> IsoValue<Date> parseBinary(final int field, final byte[] buf, final int pos,
|
||||
final CustomField<T> custom) throws ParseException {
|
||||
int[] tens = new int[2];
|
||||
int start = 0;
|
||||
if (buf.length-pos < 2) {
|
||||
|
||||
@@ -37,8 +37,8 @@ public class DateExpParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<Date> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid DATE_EXP field %d position %d",
|
||||
@@ -61,8 +61,8 @@ public class DateExpParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<Date> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid DATE_EXP field %d position %d",
|
||||
|
||||
@@ -70,8 +70,8 @@ public abstract class FieldParseInfo {
|
||||
* @param buf The full ISO message buffer.
|
||||
* @param pos The starting position for the field data.
|
||||
* @param custom A CustomField to decode the field. */
|
||||
public abstract IsoValue<?> parse(final int field, byte[] buf, int pos,
|
||||
CustomField<?> custom)
|
||||
public abstract <T> IsoValue<?> parse(final int field, byte[] buf, int pos,
|
||||
CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException;
|
||||
|
||||
/** Parses binary data from the buffer, creating and returning an IsoValue of the configured
|
||||
@@ -80,8 +80,8 @@ public abstract class FieldParseInfo {
|
||||
* @param buf The full ISO message buffer.
|
||||
* @param pos The starting position for the field data.
|
||||
* @param custom A CustomField to decode the field. */
|
||||
public abstract IsoValue<?> parseBinary(final int field, byte[] buf, int pos,
|
||||
CustomField<?> custom)
|
||||
public abstract <T> IsoValue<?> parseBinary(final int field, byte[] buf, int pos,
|
||||
CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException;
|
||||
|
||||
/** Returns a new FieldParseInfo instance that can parse the specified type. */
|
||||
|
||||
@@ -37,8 +37,8 @@ public class LlbinParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid LLBIN field %d position %d",
|
||||
@@ -62,13 +62,9 @@ public class LlbinParseInfo extends FieldParseInfo {
|
||||
return new IsoValue<byte[]>(type, binval, binval.length, null);
|
||||
} else {
|
||||
try {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(
|
||||
new String(buf, pos + 2, length)), binval.length, custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<byte[]>(type, binval, binval.length, null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(new String(buf, pos + 2, length));
|
||||
return dec == null ? new IsoValue<byte[]>(type, binval, binval.length, null) :
|
||||
new IsoValue<T>(type, dec, binval.length, custom);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
throw new ParseException(String.format(
|
||||
"Insufficient data for LLBIN field %d, pos %d (LEN states '%s')",
|
||||
@@ -78,8 +74,8 @@ public class LlbinParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid bin LLBIN field %d position %d",
|
||||
@@ -101,12 +97,9 @@ public class LlbinParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<byte[]>(type, _v, null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(HexCodec.hexEncode(_v, 0, _v.length)), custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<byte[]>(type, _v, null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(HexCodec.hexEncode(_v, 0, _v.length));
|
||||
return dec == null ? new IsoValue<byte[]>(type, _v, null) :
|
||||
new IsoValue<T>(type, dec, custom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ public class LllbinParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid LLLBIN field %d pos %d",
|
||||
@@ -64,14 +64,10 @@ public class LllbinParseInfo extends FieldParseInfo {
|
||||
return new IsoValue<byte[]>(type, binval, binval.length, null);
|
||||
} else {
|
||||
try {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(
|
||||
length == 0 ? "" : new String(buf, pos + 3, length)), length, custom);
|
||||
if (v.getValue() == null) {
|
||||
//problems decoding? return the string
|
||||
return new IsoValue<byte[]>(type, binval, binval.length, null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(
|
||||
length == 0 ? "" : new String(buf, pos + 3, length));
|
||||
return dec == null ? new IsoValue<byte[]>(type, binval, binval.length, null) :
|
||||
new IsoValue<T>(type, dec, length, custom);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
throw new ParseException(String.format(
|
||||
"Insufficient data for LLLBIN field %d, pos %d", field, pos), pos);
|
||||
@@ -80,8 +76,8 @@ public class LllbinParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid bin LLLBIN field %d pos %d",
|
||||
@@ -104,12 +100,9 @@ public class LllbinParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<byte[]>(type, _v, null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(HexCodec.hexEncode(_v, 0, _v.length)), custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<byte[]>(type, _v, null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(HexCodec.hexEncode(_v, 0, _v.length));
|
||||
return dec == null ? new IsoValue<byte[]>(type, _v, null) :
|
||||
new IsoValue<T>(type, dec, custom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ public class LllvarParseInfo extends FieldParseInfo {
|
||||
super(IsoType.LLLVAR, 0);
|
||||
}
|
||||
|
||||
public IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid LLLVAR field %d pos %d",
|
||||
@@ -74,14 +74,15 @@ public class LllvarParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<String>(type, _v, length, null);
|
||||
} else {
|
||||
Object decoded = custom.decodeField(_v);
|
||||
T decoded = custom.decodeField(_v);
|
||||
//If decode fails, return string; otherwise use the decoded object and its codec
|
||||
return new IsoValue(type, decoded == null ? _v : decoded, length, decoded == null ? null : custom);
|
||||
return decoded == null ? new IsoValue<String>(type, _v, length, null) :
|
||||
new IsoValue<T>(type, decoded, length, custom);
|
||||
}
|
||||
}
|
||||
|
||||
public IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid bin LLLVAR field %d pos %d", field, pos), pos);
|
||||
@@ -100,8 +101,7 @@ public class LllvarParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<String>(type, new String(buf, pos + 2, length, getCharacterEncoding()), null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(new String(buf, pos + 2, length, getCharacterEncoding())), custom);
|
||||
IsoValue<T> v = new IsoValue<T>(type, custom.decodeField(new String(buf, pos + 2, length, getCharacterEncoding())), custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<String>(type, new String(buf, pos + 2, length, getCharacterEncoding()), null);
|
||||
}
|
||||
|
||||
@@ -35,8 +35,9 @@ public class LlvarParseInfo extends FieldParseInfo {
|
||||
super(IsoType.LLVAR, 0);
|
||||
}
|
||||
|
||||
public IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
@Override
|
||||
public <T> IsoValue<?> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid LLVAR field %d %d", field, pos), pos);
|
||||
@@ -67,17 +68,15 @@ public class LlvarParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<String>(type, _v, length, null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(_v), length, custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<String>(type, _v, length, null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(_v);
|
||||
return dec == null ? new IsoValue<String>(type, _v, length, null) :
|
||||
new IsoValue<T>(type, dec, length, custom);
|
||||
}
|
||||
}
|
||||
|
||||
public IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
@Override
|
||||
public <T> IsoValue<?> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException, UnsupportedEncodingException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid bin LLVAR field %d pos %d",
|
||||
@@ -98,12 +97,9 @@ public class LlvarParseInfo extends FieldParseInfo {
|
||||
if (custom == null) {
|
||||
return new IsoValue<String>(type, new String(buf, pos + 1, length, getCharacterEncoding()), null);
|
||||
} else {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
IsoValue<?> v = new IsoValue(type, custom.decodeField(new String(buf, pos + 1, length, getCharacterEncoding())), custom);
|
||||
if (v.getValue() == null) {
|
||||
return new IsoValue<String>(type, new String(buf, pos + 1, length, getCharacterEncoding()), null);
|
||||
}
|
||||
return v;
|
||||
T dec = custom.decodeField(new String(buf, pos + 1, length, getCharacterEncoding()));
|
||||
return dec == null ? new IsoValue<String>(type, new String(buf, pos + 1, length, getCharacterEncoding()), null) :
|
||||
new IsoValue<T>(type, dec, custom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,9 @@ public class NumericParseInfo extends AlphaNumericFieldParseInfo {
|
||||
super(IsoType.NUMERIC, len);
|
||||
}
|
||||
|
||||
public IsoValue<Number> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
@Override
|
||||
public <T> IsoValue<Number> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid bin NUMERIC field %d pos %d",
|
||||
|
||||
@@ -38,8 +38,8 @@ public class TimeParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<Date> parse(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid TIME field %d pos %d",
|
||||
@@ -56,8 +56,8 @@ public class TimeParseInfo extends FieldParseInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsoValue<Date> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<?> custom)
|
||||
public <T> IsoValue<Date> parseBinary(final int field, final byte[] buf,
|
||||
final int pos, final CustomField<T> custom)
|
||||
throws ParseException {
|
||||
if (pos < 0) {
|
||||
throw new ParseException(String.format("Invalid bin TIME field %d pos %d",
|
||||
|
||||
Reference in New Issue
Block a user