Package com.solab.iso8583.parse
Class FieldParseInfo
- java.lang.Object
-
- com.solab.iso8583.parse.FieldParseInfo
-
- Direct Known Subclasses:
AlphaNumericFieldParseInfo
,AmountParseInfo
,BinaryParseInfo
,DateTimeParseInfo
,LlbinParseInfo
,LllbinParseInfo
,LlllbinParseInfo
,LlllvarParseInfo
,LllvarParseInfo
,LlvarParseInfo
public abstract class FieldParseInfo extends java.lang.Object
This class is used to parse a field from a message buffer. There are concrete subclasses for each IsoType.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
forceHexadecimalLength
protected boolean
forceStringDecoding
protected int
length
protected IsoType
type
-
Constructor Summary
Constructors Constructor Description FieldParseInfo(IsoType t, int len)
Creates a new instance that parses a value of the specified type, with the specified length.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int
decodeLength(byte[] buf, int pos, int digits)
java.lang.String
getCharacterEncoding()
CustomField<?>
getDecoder()
static FieldParseInfo
getInstance(IsoType t, int len, java.lang.String encoding)
Returns a new FieldParseInfo instance that can parse the specified type.int
getLength()
Returns the specified length for the data to be parsed.IsoType
getType()
Returns the data type for the data to be parsed.abstract <T> IsoValue<?>
parse(int field, byte[] buf, int pos, CustomField<T> custom)
Parses the character data from the buffer and returns the IsoValue with the correct data type in it.abstract <T> IsoValue<?>
parseBinary(int field, byte[] buf, int pos, CustomField<T> custom)
Parses binary data from the buffer, creating and returning an IsoValue of the configured type and length.void
setCharacterEncoding(java.lang.String value)
void
setDecoder(CustomField<?> value)
void
setForceHexadecimalLength(boolean flag)
Specifies whether length headers for variable-length fields in binary mode should be decoded as a hexadecimal values.void
setForceStringDecoding(boolean flag)
Specified whether length headers for variable-length fields in text mode should be decoded using proper string conversion with the character encoding.
-
-
-
Field Detail
-
type
protected IsoType type
-
length
protected final int length
-
forceStringDecoding
protected boolean forceStringDecoding
-
forceHexadecimalLength
protected boolean forceHexadecimalLength
-
-
Constructor Detail
-
FieldParseInfo
public FieldParseInfo(IsoType t, int len)
Creates a new instance that parses a value of the specified type, with the specified length. The length is only useful for ALPHA and NUMERIC types.- Parameters:
t
- The ISO type to be parsed.len
- The length of the data to be read (useful only for ALPHA and NUMERIC types).
-
-
Method Detail
-
setForceStringDecoding
public void setForceStringDecoding(boolean flag)
Specified whether length headers for variable-length fields in text mode should be decoded using proper string conversion with the character encoding. Default is false, which means use the old behavior of decoding as ASCII.
-
setForceHexadecimalLength
public void setForceHexadecimalLength(boolean flag)
Specifies whether length headers for variable-length fields in binary mode should be decoded as a hexadecimal values. Default is false, which means decoding the length as BCD.
-
setCharacterEncoding
public void setCharacterEncoding(java.lang.String value)
-
getCharacterEncoding
public java.lang.String getCharacterEncoding()
-
getLength
public int getLength()
Returns the specified length for the data to be parsed.
-
getType
public IsoType getType()
Returns the data type for the data to be parsed.
-
setDecoder
public void setDecoder(CustomField<?> value)
-
getDecoder
public CustomField<?> getDecoder()
-
parse
public abstract <T> IsoValue<?> parse(int field, byte[] buf, int pos, CustomField<T> custom) throws java.text.ParseException, java.io.UnsupportedEncodingException
Parses the character data from the buffer and returns the IsoValue with the correct data type in it.- Parameters:
field
- The field index, useful for error reporting.buf
- The full ISO message buffer.pos
- The starting position for the field data.custom
- A CustomField to decode the field.- Throws:
java.text.ParseException
java.io.UnsupportedEncodingException
-
parseBinary
public abstract <T> IsoValue<?> parseBinary(int field, byte[] buf, int pos, CustomField<T> custom) throws java.text.ParseException, java.io.UnsupportedEncodingException
Parses binary data from the buffer, creating and returning an IsoValue of the configured type and length.- Parameters:
field
- The field index, useful for error reporting.buf
- The full ISO message buffer.pos
- The starting position for the field data.custom
- A CustomField to decode the field.- Throws:
java.text.ParseException
java.io.UnsupportedEncodingException
-
getInstance
public static FieldParseInfo getInstance(IsoType t, int len, java.lang.String encoding)
Returns a new FieldParseInfo instance that can parse the specified type.
-
decodeLength
protected int decodeLength(byte[] buf, int pos, int digits) throws java.io.UnsupportedEncodingException
- Throws:
java.io.UnsupportedEncodingException
-
-