intarsys runtime library

de.intarsys.tools.tlv.common
Class SimpleElement

java.lang.Object
  extended by de.intarsys.tools.tlv.common.TlvElement
      extended by de.intarsys.tools.tlv.common.SimpleElement

public class SimpleElement
extends TlvElement

Implementation of a simple TLV object.

Each SIMPLE-TLV data object shall consist of two or three consecutive fields: a mandatory tag field, a mandatory length field and a conditional value field.

The tag field consists of a single byte encoding a tag number from 1 to 254. The values '00' and 'FF' are invalid for tag fields.

The length field consists of one or three consecutive bytes. - If the first byte is not set to 'FF', then the length field consists of a single byte encoding a number from zero to 254 and denoted N. - If the first byte is set to 'FF', then the length field continues on the subsequent two bytes with any value encoding a number from zero to 65 535 and denoted N.

If N is zero, there is no value field, i.e., the data object is empty. Otherwise (N > 0), the value field consists of N consecutive bytes.


Constructor Summary
SimpleElement(int identifier, byte[] buffer)
           
SimpleElement(int identifier, byte[] buffer, int offset, int length)
           
 
Method Summary
 TlvInputStream createTlvInputStream(byte[] pBytes, int pOffset, int pLength)
           
 byte[] getEncoded()
          The whole, encoded TLV element.
 boolean isComposite()
          true if this element contains TLV data itself.
static SimpleElement parseElement(byte[] encoded, int offset, int length)
           
static TlvTemplate parseTemplate(byte[] encoded, int offset, int length)
           
 
Methods inherited from class de.intarsys.tools.tlv.common.TlvElement
getContent, getIdentifier, getLength, getTemplate, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleElement

public SimpleElement(int identifier,
                     byte[] buffer)

SimpleElement

public SimpleElement(int identifier,
                     byte[] buffer,
                     int offset,
                     int length)
Method Detail

parseElement

public static SimpleElement parseElement(byte[] encoded,
                                         int offset,
                                         int length)
                                  throws IOException
Throws:
IOException

parseTemplate

public static TlvTemplate parseTemplate(byte[] encoded,
                                        int offset,
                                        int length)
                                 throws IOException
Throws:
IOException

createTlvInputStream

public TlvInputStream createTlvInputStream(byte[] pBytes,
                                           int pOffset,
                                           int pLength)
                                    throws TlvFormatException
Specified by:
createTlvInputStream in class TlvElement
Throws:
TlvFormatException

getEncoded

public byte[] getEncoded()
Description copied from class: TlvElement
The whole, encoded TLV element.

Specified by:
getEncoded in class TlvElement
Returns:
The whole, encoded TLV element.

isComposite

public boolean isComposite()
Description copied from class: TlvElement
true if this element contains TLV data itself.

Specified by:
isComposite in class TlvElement
Returns:
true if this element contains TLV data itself.

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.