java.lang.Object
cl.netswitch.iso.iso8583.IsoField<M,T>
- Type Parameters:
M
- the type of the ISO message.T
- the type of the field value.
- Direct Known Subclasses:
IsoBinF1
,IsoBinF2
,IsoBinF4
,IsoBinF8
,IsoBinFL
,IsoBinH8
,IsoBinV2
,IsoBinV3
,IsoDecFL
,IsoDecFS
,IsoHexFL
,IsoHexV2
,IsoHexV3
,IsoNumF10
,IsoNumF12
,IsoNumF16
,IsoNumF2
,IsoNumF3
,IsoNumF4
,IsoNumF5
,IsoNumF6
,IsoNumF7
,IsoNumF8
,IsoNumF9
,IsoNumFS8
,IsoNumFX
,IsoNumV2I
,IsoNumV2L
,IsoNumV2X
,IsoStrFL
,IsoStrV2
,IsoStrV3
,IsoStrV4
Definition of a data element of an ISO message.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
checkNumericString
(String text) Checks that all the characters of the supplied string are digits.final T
decodeAndSetValue
(ByteBuffer buffer, M message) Decodes the field value from buffer and stores value in message.abstract T
decodeValue
(ByteBuffer buffer) Decodes the value of this field from the supplied byte buffer.abstract void
encodeValue
(T value, ByteArray barray) Encodes the value of this field into the supplied byte array.final String
fieldError
(String error) Returns a string used to build exception related to this field.final String
Returns the name of the format of this field.final int
getIndex()
Returns the index of this field.final int
Returns the maximum length of this field.final int
Returns the minimum length of this field.final String
getName()
Returns the name of this field.final IsoObfuscate
Returns the obfuscate option of this field.getType()
Returns the type of the value of this field.final T
Returns the value of this field from the supplied message.final T
getValueAndEncode
(M message, ByteArray barray) Gets the field value from message and encodes into supplied byte array.final BigDecimal
readBigDecimal
(ByteBuffer buffer, int length) Returns a BigDecimal value of length digits.final BigInteger
readBigInteger
(ByteBuffer buffer, int length) Returns a BigInteger value of length digits.final char
readChar
(ByteBuffer buffer) Returns the next available character in buffer.final byte
readDigit
(ByteBuffer buffer) Returns a byte with the value of a numeric digit.final ByteBuffer
readFieldBuffer
(ByteBuffer buffer, int length) Returns a ByteBuffer with the bytes of the specified length.final long
readHex16
(ByteBuffer buffer) Reads 16 ASCII hexadecimal characters and converts them to long.final byte[]
readHexBytes
(ByteBuffer buffer, int length) Reads ASCII hexadecimal characters and returns the converted bytes.final byte
readNumber1
(ByteBuffer buffer) Returns a byte with the value of a 1 digit number.final long
readNumber10
(ByteBuffer buffer) Returns a long with the value of a 10 digit number.final long
readNumber12
(ByteBuffer buffer) Returns a long with the value of a 12 digit number.final long
readNumber14
(ByteBuffer buffer) Returns a long with the value of a 14 digit number.final byte
readNumber2
(ByteBuffer buffer) Returns a byte with the value of a 2 digit number.final short
readNumber3
(ByteBuffer buffer) Returns a short with the value of a 3 digit number.final short
readNumber4
(ByteBuffer buffer) Returns a short with the value of a 4 digit number.final int
readNumber5
(ByteBuffer buffer) Returns an integer with the value of a 5 digit number.final int
readNumber6
(ByteBuffer buffer) Returns an integer with the value of a 6 digit number.final int
readNumber7
(ByteBuffer buffer) Returns an integer with the value of a 7 digit number.final int
readNumber8
(ByteBuffer buffer) Returns an integer with the value of a 8 digit number.final int
readNumber9
(ByteBuffer buffer) Returns an integer with the value of a 9 digit number.final String
readString
(ByteBuffer buffer, int length, boolean rtrim) Returns a fixed-length string of length characters.final String
Returns the supplied string with trailing spaces removed.final void
setObfuscate
(IsoObfuscate obfuscate) Changes the obfuscate option of this field.final void
Changes the value of this field in the supplied message.final void
Writes the supplied character to given byte array.final void
Writes the supplied character to given byte array with default value.final void
writeHex16
(long value, ByteArray barray) Writes 16 ASCII hexadecimal characters of a long into byte array.final void
writeHexBytes
(byte[] bytes, int length, ByteArray barray) Writes the ASCII hexadecimal characters of bytes into byte array.final void
writeMessageValue
(M message, IsoWriter<M> writer) Writes the field value contained in message using writer.final void
writeNumber1
(byte value, ByteArray barray) Writes 1 digit of supplied byte value to a byte array.final void
writeNumber10
(long value, ByteArray barray) Writes 10 digits of supplied long value to a byte array.final void
writeNumber12
(long value, ByteArray barray) Writes 12 digits of supplied long value to a byte array.final void
writeNumber14
(long value, ByteArray barray) Writes 14 digits of supplied long value to a byte array.final int
writeNumber2
(byte value, ByteArray barray) Writes 2 digits of supplied byte value to a byte array.final int
writeNumber3
(short value, ByteArray barray) Writes 3 digits of a short value to a byte array.final int
writeNumber4
(short value, ByteArray barray) Writes 4 digits of supplied short value to a byte array.final void
writeNumber5
(int value, ByteArray barray) Writes 5 digits of supplied integer value to a byte array.final void
writeNumber6
(int value, ByteArray barray) Writes 6 digits of supplied integer value to a byte array.final void
writeNumber7
(int value, ByteArray barray) Writes 7 digits of supplied integer value to a byte array.final void
writeNumber8
(int value, ByteArray barray) Writes 8 digits of supplied integer value to a byte array.final void
writeNumber9
(int value, ByteArray barray) Writes 9 digits of supplied integer value to a byte array.final void
writeNumberLL
(ByteArray barray, int position) Writes 2 digits of field length to a byte array at position.final void
writeNumberLLL
(ByteArray barray, int position) Writes 3 digits of field length to a byte array at position.final void
writeNumberLLLL
(ByteArray barray, int position) Writes 4 digits of field length to a byte array at position.final void
writeString
(char fill, String value, int length, ByteArray barray) Writes a right-justified fixed-length string to a byte array.final void
writeString
(String value, int length, char fill, ByteArray barray) Writes a left-justified fixed-length string to a byte array.protected void
writeValue
(T value, IsoWriter<M> writer) Writes the supplied field value using the specified writer.
-
Constructor Details
-
IsoField
Constructs a newIsoField
instance.- Parameters:
index
- the index of this field.format
- the format of this field.minlen
- min number of elements of this field value.maxlen
- max number of elements of this field value.vtype
- the class type of this field value.name
- the name of this field.- Throws:
NullPointerException
- if an argument isnull
.IllegalArgumentException
- if an argument is invalid.
-
-
Method Details
-
getIndex
public final int getIndex()Returns the index of this field.- Returns:
- the index of this field.
-
getFormat
Returns the name of the format of this field.- Returns:
- the name of the format of this field.
-
getMinLength
public final int getMinLength()Returns the minimum length of this field.- Returns:
- the minimum length of this field.
-
getMaxLength
public final int getMaxLength()Returns the maximum length of this field.- Returns:
- the maximum length of this field.
-
getName
Returns the name of this field.- Returns:
- the name of this field.
-
getType
Returns the type of the value of this field.- Returns:
- the type of the value of this field.
-
getObfuscate
Returns the obfuscate option of this field.- Returns:
- the obfuscate option of this field.
-
setObfuscate
Changes the obfuscate option of this field.- Parameters:
obfuscate
- the new obfuscate option.- Throws:
NullPointerException
- ifobfuscate
isnull
.
-
decodeAndSetValue
Decodes the field value from buffer and stores value in message.- Parameters:
buffer
- the buffer containing the encoded field value.message
- the message where the field value is stored.- Returns:
- the non-null field value decoded from buffer.
- Throws:
NullPointerException
- if an argument isnull
.IsoException
- if an expected decoder error occurs.
-
setValue
Changes the value of this field in the supplied message.- Parameters:
message
- the message to be modified.value
- the new value of this field (can be null).- Throws:
NullPointerException
- ifmessage
isnull
.IllegalArgumentException
- ifvalue
is invalid.IsoException
- if another error occurs changing the value.
-
decodeValue
Decodes the value of this field from the supplied byte buffer.- Parameters:
buffer
- the buffer containing the encoded field value.- Returns:
- the value decoded from supplied byte buffer.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
getValueAndEncode
Gets the field value from message and encodes into supplied byte array.- Parameters:
message
- the message that contains the field value.barray
- the byte array containing encoded field values.- Returns:
- the field value that was encoded into the byte array.
- Throws:
NullPointerException
- if an argument isnull
.ClassCastException
- if the field value is of wrong type.IsoException
- if the field value in message is invalid.
-
getValue
Returns the value of this field from the supplied message.- Parameters:
message
- the message that contains the field value.- Returns:
- the value of this field read from supplied message.
- Throws:
NullPointerException
- ifmessage
isnull
.ClassCastException
- if the retrieved value is invalid.IsoException
- if another error occurs getting the value.
-
encodeValue
Encodes the value of this field into the supplied byte array.- Parameters:
value
- the field value to be encoded into byte array.barray
- the byte array containing encoded field values.- Throws:
NullPointerException
- if an argument isnull
.IsoException
- ifvalue
is invalid.
-
writeMessageValue
Writes the field value contained in message using writer.- Parameters:
message
- the message that contains the field value.writer
- the writer used to write the field value.- Throws:
NullPointerException
- if an argument isnull
.ClassCastException
- if type of field value is invalid.IsoException
- if another error occurs.
-
writeValue
Writes the supplied field value using the specified writer.- Parameters:
value
- the field value to write with writer.writer
- the writer used to write the field value.- Throws:
NullPointerException
- if an argument isnull
.IsoException
- if another error occurs.
-
fieldError
Returns a string used to build exception related to this field.- Parameters:
error
- a description of the error condition found.- Returns:
- a string used to build errors related to this field.
-
rightTrim
Returns the supplied string with trailing spaces removed.- Parameters:
str
- the string to be inspected.- Returns:
- the supplied string with trailing spaces removed.
- Throws:
NullPointerException
- ifstr
isnull
.
-
readFieldBuffer
Returns a ByteBuffer with the bytes of the specified length.- Parameters:
buffer
- the buffer containing the variable-length field value.length
- the number of bytes to read inbuffer
.- Returns:
- a ByteBuffer with the byte array of the specified length.
- Throws:
NullPointerException
- ifbuffer
isnull
.BufferUnderflowException
- ifbuffer
is missing bytes.
-
readDigit
Returns a byte with the value of a numeric digit.- Parameters:
buffer
- the buffer containing the digit.- Returns:
- a byte with the value of a numeric digit.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
readNumber1
Returns a byte with the value of a 1 digit number.- Parameters:
buffer
- the buffer containing the digit.- Returns:
- a byte with the value of a 1 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber1
Writes 1 digit of supplied byte value to a byte array.- Parameters:
value
- the byte value to be written to barray.barray
- the byte array where the digit are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber2
Returns a byte with the value of a 2 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- a byte with the value of a 2 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber2
Writes 2 digits of supplied byte value to a byte array.- Parameters:
value
- the byte value to be written to barray.barray
- the byte array where the digits are written.- Returns:
- the absolute index where the byte value was written.
- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
writeNumberLL
Writes 2 digits of field length to a byte array at position.- Parameters:
barray
- the byte array where the digits are written.position
- the absolute position to write the field length.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber3
Returns a short with the value of a 3 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- a short with the value of a 3 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber3
Writes 3 digits of a short value to a byte array.- Parameters:
value
- the short value to be written to barray.barray
- the byte array where the digits are written.- Returns:
- the absolute index where the short value was written.
- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
writeNumberLLL
Writes 3 digits of field length to a byte array at position.- Parameters:
barray
- the byte array where the digits are written.position
- the absolute position to write the field length.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber4
Returns a short with the value of a 4 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- a short with the value of a 4 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber4
Writes 4 digits of supplied short value to a byte array.- Parameters:
value
- the short value to be written to barray.barray
- the byte array where the digits are written.- Returns:
- the absolute index where the short value was written.
- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
writeNumberLLLL
Writes 4 digits of field length to a byte array at position.- Parameters:
barray
- the byte array where the digits are written.position
- the absolute position to write the field length.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber5
Returns an integer with the value of a 5 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- an integer with the value of a 5 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber5
Writes 5 digits of supplied integer value to a byte array.- Parameters:
value
- the integer value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber6
Returns an integer with the value of a 6 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- an integer with the value of a 6 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber6
Writes 6 digits of supplied integer value to a byte array.- Parameters:
value
- the integer value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber7
Returns an integer with the value of a 7 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- an integer with the value of a 7 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber7
Writes 7 digits of supplied integer value to a byte array.- Parameters:
value
- the integer value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber8
Returns an integer with the value of a 8 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- an integer with the value of a 8 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber8
Writes 8 digits of supplied integer value to a byte array.- Parameters:
value
- the integer value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber9
Returns an integer with the value of a 9 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- an integer with the value of a 9 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber9
Writes 9 digits of supplied integer value to a byte array.- Parameters:
value
- the integer value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber10
Returns a long with the value of a 10 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- a long with the value of a 10 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber10
Writes 10 digits of supplied long value to a byte array.- Parameters:
value
- the long value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber12
Returns a long with the value of a 12 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- a long with the value of a 12 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber12
Writes 12 digits of supplied long value to a byte array.- Parameters:
value
- the long value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readNumber14
Returns a long with the value of a 14 digit number.- Parameters:
buffer
- the buffer containing the digits.- Returns:
- a long with the value of a 14 digit number.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeNumber14
Writes 14 digits of supplied long value to a byte array.- Parameters:
value
- the long value to be written to barray.barray
- the byte array where the digits are written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- ifvalue
is out-of-range.
-
readBigDecimal
Returns a BigDecimal value of length digits.- Parameters:
buffer
- the buffer containing the digits.length
- the number of digits of the value.- Returns:
- a BigDecimal value read from supplied buffer.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
readBigInteger
Returns a BigInteger value of length digits.- Parameters:
buffer
- the buffer containing the digits.length
- the number of digits of the value.- Returns:
- a BigInteger value read from supplied buffer.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
checkNumericString
Checks that all the characters of the supplied string are digits.- Parameters:
text
- the string to be inspected and checked.- Throws:
NullPointerException
- iftext
isnull
.IsoException
- iftext
contains non-digit chars.
-
readChar
Returns the next available character in buffer.- Parameters:
buffer
- the buffer containing the character.- Returns:
- the next available character in buffer.
- Throws:
NullPointerException
- ifbuffer
isnull
.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeChar
Writes the supplied character to given byte array.- Parameters:
value
- the character to be written to barray.barray
- the byte array where the character is written.- Throws:
NullPointerException
- ifbarray
isnull
.
-
writeChar
Writes the supplied character to given byte array with default value.- Parameters:
ch
- the character to be written to barray (can be null).defval
- the default value written ifch
isnull
.barray
- the byte array where the character is written.- Throws:
NullPointerException
- ifbarray
isnull
.
-
readString
Returns a fixed-length string of length characters.- Parameters:
buffer
- the buffer containing the fixed-length string.length
- the number of required string characters.rtrim
- iftrue
the string is right-trimmed.- Returns:
- a fixed-length string of length characters.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeString
Writes a left-justified fixed-length string to a byte array.- Parameters:
value
- the string to be written to barray (can be null).length
- the length of the fixed-length of the string.fill
- the character used to right-fill to complete length.barray
- the byte array where the string is written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- if stringvalue
is too long.
-
writeString
Writes a right-justified fixed-length string to a byte array.- Parameters:
fill
- the character used to left-fill to complete length.value
- the string to be written to barray (can be null).length
- the length of the fixed-length of the string.barray
- the byte array where the string is written.- Throws:
NullPointerException
- ifbarray
isnull
.IsoException
- if stringvalue
is too long.
-
readHexBytes
Reads ASCII hexadecimal characters and returns the converted bytes.- Parameters:
buffer
- the buffer containing hexadecimal characters.length
- the number of hexadecimal characters to read.- Returns:
- the byte array built using input hexadecimal characters.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- iflength
is negative or not even.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeHexBytes
Writes the ASCII hexadecimal characters of bytes into byte array.- Parameters:
bytes
- the array of bytes to be converted.length
- the number of hexadecimal characters to write.barray
- the byte array where the bytes are written.- Throws:
NullPointerException
- if an argument isnull
.IsoException
- ifbytes
is too long.
-
readHex16
Reads 16 ASCII hexadecimal characters and converts them to long.- Parameters:
buffer
- the buffer containing hexadecimal characters.- Returns:
- the long built with input hexadecimal characters.
- Throws:
NullPointerException
- ifbuffer
isnull
.IsoException
- if contents ofbuffer
is invalid.BufferUnderflowException
- ifbuffer
is missing bytes.
-
writeHex16
Writes 16 ASCII hexadecimal characters of a long into byte array.- Parameters:
value
- the long to be converted and written to barray.barray
- the byte array where the long is written.- Throws:
NullPointerException
- ifbarray
isnull
.
-