Class KlvDecoder

java.lang.Object
org.codice.ddf.libs.klv.KlvDecoder

public class KlvDecoder extends Object
Decodes bytes that contain KLV-encoded data.
  • Constructor Details

    • KlvDecoder

      public KlvDecoder(KlvContext klvContext)
      Creates a KlvDecoder with the given KlvContext.
      Parameters:
      klvContext - the KlvContext containing the properties of the KLV data to be decoded by this KlvDecoder
  • Method Details

    • decode

      public KlvContext decode(byte[] klvBytes) throws KlvDecodingException
      Decodes the KLV data inside klvBytes according to the properties in the KlvContext that was provided in the constructor.

      It will recursively decode any KlvLocalSets it finds, provided that they are given in the KlvContext.

      The decoded KLV values are returned in a new KlvContext object that has the same structure as the KlvContext that was provided in the constructor but contains only the KlvDataElements that were found in the given bytes.

      Parameters:
      klvBytes - bytes encoding data in KLV format
      Returns:
      a new KlvContext containing the decoded KLV data elements
      Throws:
      IllegalArgumentException - if klvBytes is null
      KlvDecodingException - if the KLV cannot be decoded using the given context information