public class KlvContext extends Object
KlvContext specifies the key
length and length encoding type for the data elements (the fundamental units of KLV) in the data
as well as what data elements can be found within.
Basically, this class makes it possible to decode KLV-encoded data with an arbitrary structure. The value portion of each KLV set can contain either a raw data value (such as a number or string) or another chain of data elements (sometimes called a local set). So, whatever is decoding it needs to know how to interpret the values of the data elements it finds. This class allows you to provide that information so your KLV can be decoded.
In essence, a KlvContext represents the structure of the encoded KLV data you wish to
decode.
| Constructor and Description |
|---|
KlvContext(Klv.KeyLength keyLength,
Klv.LengthEncoding lengthEncoding)
Constructs a
KlvContext containing the properties of a specific KLV-encoded data set. |
KlvContext(Klv.KeyLength keyLength,
Klv.LengthEncoding lengthEncoding,
Collection<? extends KlvDataElement> dataElements)
Constructs a
KlvContext containing the properties of a specific KLV-encoded data set,
including the data elements that could possibly be found within the data. |
| Modifier and Type | Method and Description |
|---|---|
void |
addDataElement(KlvDataElement dataElement)
Adds a
KlvDataElement to the KlvContext. |
void |
addDataElements(Collection<? extends KlvDataElement> dataElements)
Adds multiple
KlvDataElements to the KlvContext. |
KlvDataElement |
getDataElementByName(String name)
Returns the
KlvDataElement in this KlvContext with the given name. |
Map<String,KlvDataElement> |
getDataElements()
Returns the
KlvDataElements inside this KlvContext as a Map, where the
keys are the data elements' names and the values are the data elements. |
Klv.KeyLength |
getKeyLength() |
Klv.LengthEncoding |
getLengthEncoding() |
boolean |
hasDataElement(String name)
Determines whether this
KlvContext contains a KlvDataElement with the given
name. |
public KlvContext(Klv.KeyLength keyLength, Klv.LengthEncoding lengthEncoding)
KlvContext containing the properties of a specific KLV-encoded data set.keyLength - the key length of the data elements inside the KLV-encoded datalengthEncoding - the length encoding method of the data elements inside the KLV-encoded
dataIllegalArgumentException - if any of the arguments are nullpublic KlvContext(Klv.KeyLength keyLength, Klv.LengthEncoding lengthEncoding, Collection<? extends KlvDataElement> dataElements)
KlvContext containing the properties of a specific KLV-encoded data set,
including the data elements that could possibly be found within the data.keyLength - the key length of the data elements inside the KLV-encoded datalengthEncoding - the length encoding method of the date elements inside the KLV-encoded
datadataElements - the data elements that could possibly be found inside the dataIllegalArgumentException - if any of the arguments are nullpublic void addDataElement(KlvDataElement dataElement)
KlvDataElement to the KlvContext.dataElement - the KlvDataElement to addIllegalArgumentException - if the argument is nullpublic void addDataElements(Collection<? extends KlvDataElement> dataElements)
KlvDataElements to the KlvContext.dataElements - the KlvDataElements to addIllegalArgumentException - if the argument is nullpublic Klv.KeyLength getKeyLength()
public Klv.LengthEncoding getLengthEncoding()
public Map<String,KlvDataElement> getDataElements()
KlvDataElements inside this KlvContext as a Map, where the
keys are the data elements' names and the values are the data elements.Map containing the KlvDataElements inside this KlvContextpublic boolean hasDataElement(String name)
KlvContext contains a KlvDataElement with the given
name.name - the data element's nameKlvContext contains a data element with the name namepublic KlvDataElement getDataElementByName(String name)
KlvDataElement in this KlvContext with the given name.name - the data element's nameKlvDataElement in this KlvContext with the name name, or
null if this KlvContext does not have a KlvDataElement with the name nameThis work is licensed under a Creative Commons Attribution 4.0 International License.