Package org.codice.ddf.libs.klv
Class KlvDecoder
java.lang.Object
org.codice.ddf.libs.klv.KlvDecoder
Decodes bytes that contain KLV-encoded data.
-
Constructor Summary
ConstructorsConstructorDescriptionKlvDecoder(KlvContext klvContext) Creates aKlvDecoderwith the givenKlvContext. -
Method Summary
Modifier and TypeMethodDescriptiondecode(byte[] klvBytes) Decodes the KLV data insideklvBytesaccording to the properties in theKlvContextthat was provided in the constructor.
-
Constructor Details
-
KlvDecoder
Creates aKlvDecoderwith the givenKlvContext.- Parameters:
klvContext- theKlvContextcontaining the properties of the KLV data to be decoded by thisKlvDecoder
-
-
Method Details
-
decode
Decodes the KLV data insideklvBytesaccording to the properties in theKlvContextthat was provided in the constructor.It will recursively decode any
KlvLocalSets it finds, provided that they are given in theKlvContext.The decoded KLV values are returned in a new
KlvContextobject that has the same structure as theKlvContextthat was provided in the constructor but contains only theKlvDataElements that were found in the given bytes.- Parameters:
klvBytes- bytes encoding data in KLV format- Returns:
- a new
KlvContextcontaining the decoded KLV data elements - Throws:
IllegalArgumentException- ifklvBytesis nullKlvDecodingException- if the KLV cannot be decoded using the given context information
-