Class TLVList
java.lang.Object
org.jpos.tlv.TLVList
- All Implemented Interfaces:
Serializable, Loggeable
An ordered list of TLV (Tag-Length-Value) records.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(int tag, byte[] value) Append TLVMsg to the TLVList.Append TLVMsg to the TLVList.voidAppend TLVMsg to the TLV list.protected TLVMsgcreateTLVMsg(int tag, byte[] value) Create TLV message instance.voiddeleteByIndex(int index) delete the specified TLV from the list using a Zero based indexvoiddeleteByTag(int tag) Delete the specified TLV from the list by tag valuevoiddump(PrintStream p, String indent) Dumps a human-readable representation of this object to the print stream.elements()Returns the decoded tags as an enumeration.find(int tag) Searches the list for a specified tag and returns a TLV object.intfindIndex(int tag) Searches the list for a specified tag and returns a zero based index for that tag.Return the next TLVMsg of same TAG value.getString(int tag) searches the list for a specified tag and returns a hex StringgetTags()Returns the decoded tags in insertion order.byte[]getValue(int tag) searches the list for a specified tag and returns it rawprotected intgetValueLength(ByteBuffer buffer) Read length bytes and return the int valuebooleanhasTag(int tag) Indicates if TLV measege with passedtagis on list.index(int index) Returns aTLVMsginstance stored within theTLVListat the givenindex.byte[]pack()Pack the TLV message (BER-TLV Encoding).voidunpack(byte[] buf) Unpacks a TLV-encoded message.voidunpack(byte[] buf, int offset) Unpacks a TLV-encoded message starting at the provided offset.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Loggeable
dumpModifier and TypeMethodDescriptiondefault voiddump(PrintStream p, String indent, LogRenderer.Type type) Dumps a representation of this object using the specified renderer type.
-
Constructor Details
-
TLVList
public TLVList()Creates instance of TLV engine.It is a shorter form of:
TLVListBuilder.createInstance().build();
-
-
Method Details
-
unpack
Unpacks a TLV-encoded message.- Parameters:
buf- raw message- Throws:
IllegalArgumentException- if the buffer contains an invalid TLV structure
-
getTags
-
elements
Returns the decoded tags as an enumeration.- Returns:
- an enumeration of the list of tags
-
unpack
public void unpack(byte[] buf, int offset) throws IllegalArgumentException, IndexOutOfBoundsException Unpacks a TLV-encoded message starting at the provided offset.- Parameters:
buf- raw messageoffset- the offset- Throws:
IndexOutOfBoundsException- ifoffsetexceedsbuf.lengthIllegalArgumentException- if the buffer contains an invalid TLV structure
-
append
Append TLVMsg to the TLV list.- Parameters:
tlv- the TLV message- Throws:
NullPointerException- iftlvisnull
-
append
Append TLVMsg to the TLVList.- Parameters:
tag- tag idvalue- tag value- Returns:
- the TLV list instance
- Throws:
IllegalArgumentException- when contains tag with illegal id
-
append
Append TLVMsg to the TLVList.- Parameters:
tag- idvalue- in hexadecimal character representation- Returns:
- the TLV list instance
- Throws:
IllegalArgumentException- when contains tag with illegal id
-
deleteByIndex
delete the specified TLV from the list using a Zero based index- Parameters:
index- number
-
deleteByTag
Delete the specified TLV from the list by tag value- Parameters:
tag- id
-
find
-
findIndex
Searches the list for a specified tag and returns a zero based index for that tag.- Parameters:
tag- tag identifier- Returns:
- index for a given
tag
-
findNextTLV
Return the next TLVMsg of same TAG value.- Returns:
- TLV message or
nullif not found. - Throws:
IllegalStateException- when the search has not been initiated
-
index
Returns aTLVMsginstance stored within theTLVListat the givenindex.- Parameters:
index- zero based index of TLV message- Returns:
- TLV message instance
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())
-
pack
-
createTLVMsg
Create TLV message instance.- Parameters:
tag- tag identifiervalue- the value of tag- Returns:
- TLV message instance
- Throws:
IllegalArgumentException- when contains tag with illegal id- API Note:
- The protected scope is intended to not promote the use of TLVMsg outside.
-
getValueLength
Read length bytes and return the int value- Parameters:
buffer- buffer- Returns:
- value length
- Throws:
IllegalArgumentException- if the encoded length cannot be parsed
-
getString
-
getValue
searches the list for a specified tag and returns it raw- Parameters:
tag- id- Returns:
- byte[]
-
hasTag
Indicates if TLV measege with passedtagis on list.- Parameters:
tag- tag identifier- Returns:
trueif tag contains on list,falseotherwise
-
dump
-