test_class.declarator: LOG = LoggerFactory.getLogger(TlvDecoderTest.class)
test_class.modifier: private static
test_class.original_string: private static Logger LOG = LoggerFactory.getLogger(TlvDecoderTest.class);
test_class.type: Logger
test_class.var_name: LOG
test_class.file: leshan-core/src/test/java/org/eclipse/leshan/core/tlv/TlvDecoderTest.java
test_class.identifier: TlvDecoderTest
test_case.body: @Test
      public void decode_device_object() throws TlvException {
          // // the /3// from liwblwm2m
          String dataStr = "C800144F70656E204D6F62696C6520416C6C69616E6365C801164C69676874776569676874204D324D20436C69656E74C80209333435303030313233C303312E30860641000141010588070842000ED842011388870841007D42010384C10964C10A0F830B410000C40D5182428FC60E2B30323A3030C10F55";
          byte[] bytes = Hex.decodeHex(dataStr.toCharArray());
          ByteBuffer b = ByteBuffer.wrap(bytes);
          Tlv[] tlv = TlvDecoder.decode(b);
          LOG.debug(Arrays.toString(tlv));
  
          ByteBuffer buff = TlvEncoder.encode(tlv);
          assertTrue(Arrays.equals(bytes, buff.array()));
      }
test_case.class_method_signature: TlvDecoderTest.decode_device_object()
test_case.full_signature: @Test public void decode_device_object()
test_case.identifier: decode_device_object
test_case.invocations: decodeHex toCharArray wrap decode debug toString encode assertTrue equals array
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void decode_device_object()
focal_class.declarator: LOG = LoggerFactory.getLogger(TlvDecoder.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(TlvDecoder.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.file: leshan-core/src/main/java/org/eclipse/leshan/core/tlv/TlvDecoder.java
focal_class.identifier: TlvDecoder
focal_class.class_method_signature: TlvDecoder.decode(ByteBuffer input)
focal_class.full_signature: public static Tlv[] decode(ByteBuffer input)
focal_class.identifier: decode
focal_class.modifiers: public static
focal_class.parameters: (ByteBuffer input)
focal_class.return: Tlv[]
focal_class.signature: Tlv[] decode(ByteBuffer input)
focal_class.class_method_signature: TlvDecoder.decodeString(byte[] value)
focal_class.full_signature: public static String decodeString(byte[] value)
focal_class.identifier: decodeString
focal_class.modifiers: public static
focal_class.parameters: (byte[] value)
focal_class.return: String
focal_class.signature: String decodeString(byte[] value)
focal_class.class_method_signature: TlvDecoder.decodeBoolean(byte[] value)
focal_class.full_signature: public static boolean decodeBoolean(byte[] value)
focal_class.identifier: decodeBoolean
focal_class.modifiers: public static
focal_class.parameters: (byte[] value)
focal_class.return: boolean
focal_class.signature: boolean decodeBoolean(byte[] value)
focal_class.class_method_signature: TlvDecoder.decodeDate(byte[] value)
focal_class.full_signature: public static Date decodeDate(byte[] value)
focal_class.identifier: decodeDate
focal_class.modifiers: public static
focal_class.parameters: (byte[] value)
focal_class.return: Date
focal_class.signature: Date decodeDate(byte[] value)
focal_class.class_method_signature: TlvDecoder.decodeObjlnk(byte[] value)
focal_class.full_signature: public static ObjectLink decodeObjlnk(byte[] value)
focal_class.identifier: decodeObjlnk
focal_class.modifiers: public static
focal_class.parameters: (byte[] value)
focal_class.return: ObjectLink
focal_class.signature: ObjectLink decodeObjlnk(byte[] value)
focal_class.class_method_signature: TlvDecoder.decodeInteger(byte[] value)
focal_class.full_signature: public static Number decodeInteger(byte[] value)
focal_class.identifier: decodeInteger
focal_class.modifiers: public static
focal_class.parameters: (byte[] value)
focal_class.return: Number
focal_class.signature: Number decodeInteger(byte[] value)
focal_class.class_method_signature: TlvDecoder.decodeFloat(byte[] value)
focal_class.full_signature: public static Number decodeFloat(byte[] value)
focal_class.identifier: decodeFloat
focal_class.modifiers: public static
focal_class.parameters: (byte[] value)
focal_class.return: Number
focal_class.signature: Number decodeFloat(byte[] value)
focal_method.body: public static Tlv[] decode(ByteBuffer input) throws TlvException {
  
          try {
              List<Tlv> tlvs = new ArrayList<>();
  
              while (input.remaining() > 0) {
                  input.order(ByteOrder.BIG_ENDIAN);
  
                  // decode type
                  int typeByte = input.get() & 0xFF;
                  TlvType type;
                  switch (typeByte & 0b1100_0000) {
                  case 0b0000_0000:
                      type = TlvType.OBJECT_INSTANCE;
                      break;
                  case 0b0100_0000:
                      type = TlvType.RESOURCE_INSTANCE;
                      break;
                  case 0b1000_0000:
                      type = TlvType.MULTIPLE_RESOURCE;
                      break;
                  case 0b1100_0000:
                      type = TlvType.RESOURCE_VALUE;
                      break;
                  default:
                      throw new TlvException("unknown type: " + (typeByte & 0b1100_0000));
                  }
  
                  // decode identifier
                  int identifier;
                  try {
                      if ((typeByte & 0b0010_0000) == 0) {
                          identifier = input.get() & 0xFF;
                      } else {
                          identifier = input.getShort() & 0xFFFF;
                      }
                  } catch (BufferUnderflowException e) {
                      throw new TlvException("Invalid 'identifier' length", e);
                  }
                  LOG.trace("decoding {} {}", type, identifier);
  
                  // decode length
                  int length;
                  int lengthType = typeByte & 0b0001_1000;
                  try {
                      switch (lengthType) {
                      case 0b0000_0000:
                          // 2 bit length
                          length = typeByte & 0b0000_0111;
                          break;
                      case 0b0000_1000:
                          // 8 bit length
                          length = input.get() & 0xFF;
                          break;
                      case 0b0001_0000:
                          // 16 bit length
                          length = input.getShort() & 0xFFFF;
                          break;
                      case 0b0001_1000:
                          // 24 bit length
                          int b = input.get() & 0x000000FF;
                          int s = input.getShort() & 0x0000FFFF;
                          length = (b << 16) | s;
                          break;
                      default:
                          throw new TlvException("unknown length type: " + (typeByte & 0b0001_1000));
                      }
                  } catch (BufferUnderflowException e) {
                      throw new TlvException("Invalid 'length' length", e);
                  }
                  LOG.trace("length: {} (length type: {})", length, lengthType);
  
                  // decode value
                  if (type == TlvType.RESOURCE_VALUE || type == TlvType.RESOURCE_INSTANCE) {
                      try {
                          byte[] payload = new byte[length];
                          input.get(payload);
                          tlvs.add(new Tlv(type, null, payload, identifier));
  
                          if (LOG.isTraceEnabled()) {
                              LOG.trace("payload value: {}", Hex.encodeHexString(payload));
                          }
                      } catch (BufferOverflowException e) {
                          throw new TlvException("Invalid 'value' length", e);
                      }
                  } else {
                      try {
                          // create a view of the contained TLVs
                          ByteBuffer slice = input.slice();
                          // HACK the cast is necessary for binary backward compatibility bug introduce in Java 9
                          // https://github.com/apache/felix/pull/114
                          ((Buffer) slice).limit(length);
  
                          Tlv[] children = decode(slice);
  
                          // skip the children, it will be decoded by the view
                          // HACK the cast is necessary for binary backward compatibility bug introduce in Java 9
                          // https://github.com/apache/felix/pull/114
                          ((Buffer) input).position(((Buffer) input).position() + length);
  
                          Tlv tlv = new Tlv(type, children, null, identifier);
                          tlvs.add(tlv);
                      } catch (IllegalArgumentException e) {
                          throw new TlvException("Invalid 'value' length", e);
                      }
                  }
              }
  
              return tlvs.toArray(new Tlv[] {});
          } catch (TlvException ex) {
              String printHexBinary = Hex.encodeHexString(input.array());
              throw new TlvException("Impossible to parse TLV: \n" + printHexBinary, ex);
          } catch (RuntimeException ex) {
              String printHexBinary = Hex.encodeHexString(input.array());
              throw new TlvException("Unexpected TLV parse error: \n" + printHexBinary, ex);
          }
      }
focal_method.class_method_signature: TlvDecoder.decode(ByteBuffer input)
focal_method.full_signature: public static Tlv[] decode(ByteBuffer input)
focal_method.identifier: decode
focal_method.invocations: remaining order get get getShort trace get getShort get getShort trace get add isTraceEnabled trace encodeHexString slice limit decode position position add toArray encodeHexString array encodeHexString array
focal_method.modifiers: public static
focal_method.parameters: (ByteBuffer input)
focal_method.return: Tlv[]
focal_method.signature: Tlv[] decode(ByteBuffer input)