org.apache.asn1.ber
Class Tag

java.lang.Object
  extended by org.apache.asn1.ber.Tag

public class Tag
extends java.lang.Object

The Tag component of a BER TLV Tuple.

Version:
$Rev: 157644 $
Author:
Apache Directory Project

Field Summary
private  TagOctetCollector buf
          buffer backed by a Java int to collect the arriving tag octets
private static int CONSTRUCTED_FLAG
          tag flag for the primitive/constructed bit - 0010 0000 - 0x20
private static int FOUR_OCTET_IDMAX
          the max id size with four tag octets
private  int id
          tag id
private  boolean isFixated
          whether or not this tag has been fixated
private  boolean isPrimitive
          whether or not this tag represents a primitive type
private static int LONG_FLAG
          tag flag indicating the use of the long tag encoding form
(package private) static int LONG_MASK
          tag mask for the long tag format - 0111 1111 - 0x7F
private static int ONE_OCTET_IDMAX
          the max id size with one tag octet
(package private) static int SHORT_MASK
          tag mask for the short tag format - 0001 1111 - 0x1F
private static int THREE_OCTET_IDMAX
          the max id size with three tag octets
private static int TWO_OCTET_IDMAX
          the max id size with two tag octets
private  TypeClass typeClass
          the type class of this tag
 
Constructor Summary
Tag()
           
 
Method Summary
(package private)  void add(byte octet)
          Adds an octet to this Tag and as a size effect may fixate the Tag if all the expected data has arrived.
(package private)  void clear()
          Clears this tag's data of all bytes and values calculated so all is as it was when this instance was created.
(package private)  void fixate()
          Fixates the data within this Tag calculating all the derived properties from the existing set of octets.
 int getId()
          Gets the id.
static int getIntEncodedTag(TypeClass type, int id, boolean isConstructed)
          Assembles the Java primitive int based encoding for a tag using a set of parameters.
 byte[] getOctets()
          Gets a copy of the octets composing this Tag.
 int getRawTag()
          Gets the raw tag as it is stuffed into a primitive int.
static int getTagId(byte[] octets)
          Gets the tag id of a TLV from tag octets.
static int getTagId(int octets)
          Gets the tag id of a TLV from tag octets encoded as a Java primitive int.
static int getTagId(TagOctetCollector octets)
          Gets the tag id of a TLV from the tag octets.
 TypeClass getTypeClass()
          Gets the type class for this Tag.
static boolean isConstructed(int octet)
          Checks to see if the tag is constructed.
 boolean isFixated()
          Checks to see if the tag has been fixated.
 boolean isPrimitive()
          Checks to see if the tag represented by this Tag is primitive or constructed.
static boolean isPrimitive(int octet)
          Checks to see if the tag is a primitive.
static boolean isRawTagConstructed(int rawTag)
           
static int setIntEncodedId(int encodedTag, int id)
          Sets the id of a tag encoded as a Java primitive integer.
 int size()
          Gets the number of octets in this Tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTRUCTED_FLAG

private static final int CONSTRUCTED_FLAG
tag flag for the primitive/constructed bit - 0010 0000 - 0x20

See Also:
Constant Field Values

SHORT_MASK

static final int SHORT_MASK
tag mask for the short tag format - 0001 1111 - 0x1F

See Also:
Constant Field Values

LONG_MASK

static final int LONG_MASK
tag mask for the long tag format - 0111 1111 - 0x7F

See Also:
Constant Field Values

LONG_FLAG

private static final int LONG_FLAG
tag flag indicating the use of the long tag encoding form

See Also:
Constant Field Values

ONE_OCTET_IDMAX

private static final int ONE_OCTET_IDMAX
the max id size with one tag octet

See Also:
Constant Field Values

TWO_OCTET_IDMAX

private static final int TWO_OCTET_IDMAX
the max id size with two tag octets

See Also:
Constant Field Values

THREE_OCTET_IDMAX

private static final int THREE_OCTET_IDMAX
the max id size with three tag octets

See Also:
Constant Field Values

FOUR_OCTET_IDMAX

private static final int FOUR_OCTET_IDMAX
the max id size with four tag octets

See Also:
Constant Field Values

id

private int id
tag id


isPrimitive

private boolean isPrimitive
whether or not this tag represents a primitive type


isFixated

private boolean isFixated
whether or not this tag has been fixated


typeClass

private TypeClass typeClass
the type class of this tag


buf

private final TagOctetCollector buf
buffer backed by a Java int to collect the arriving tag octets

Constructor Detail

Tag

public Tag()
Method Detail

clear

void clear()
Clears this tag's data of all bytes and values calculated so all is as it was when this instance was created.


fixate

void fixate()
      throws org.apache.asn1.codec.DecoderException
Fixates the data within this Tag calculating all the derived properties from the existing set of octets. While fixated octets cannot be added.

Throws:
org.apache.asn1.codec.DecoderException - if this Tag is invalid

add

void add(byte octet)
   throws org.apache.asn1.codec.DecoderException
Adds an octet to this Tag and as a size effect may fixate the Tag if all the expected data has arrived.

Parameters:
octet - the 8 bit byte to add
Throws:
org.apache.asn1.codec.DecoderException

getOctets

public byte[] getOctets()
Gets a copy of the octets composing this Tag.

Returns:
the octets representing this Tag

size

public int size()
Gets the number of octets in this Tag.

Returns:
the number of octets within this Tag

getId

public int getId()
Gets the id.

Returns:
the id

getRawTag

public int getRawTag()
Gets the raw tag as it is stuffed into a primitive int.

Returns:
a primitive int stuffed with the first four octets of the tag

isPrimitive

public boolean isPrimitive()
Checks to see if the tag represented by this Tag is primitive or constructed.

Returns:
true if it is primitive, false if it is constructed

isFixated

public boolean isFixated()
Checks to see if the tag has been fixated.

Returns:
true if it is fixated, false if not

getTypeClass

public TypeClass getTypeClass()
Gets the type class for this Tag.

Returns:
the typeClass for this Tag

setIntEncodedId

public static final int setIntEncodedId(int encodedTag,
                                        int id)
Sets the id of a tag encoded as a Java primitive integer.

Parameters:
encodedTag - the tag encoded as a Java primitive integer
id - the new tag id to set within the encodedTag
Returns:
the modified Java primitive int encoded tag with the new tag id

getIntEncodedTag

public static final int getIntEncodedTag(TypeClass type,
                                         int id,
                                         boolean isConstructed)
Assembles the Java primitive int based encoding for a tag using a set of parameters.

Parameters:
type -
id -
isConstructed -
Returns:

getTagId

public static final int getTagId(byte[] octets)
                          throws org.apache.asn1.codec.DecoderException
Gets the tag id of a TLV from tag octets.

Parameters:
octets - the set of octets needed to determine the tag value (a.k.a identifier octets)
Returns:
the tag id
Throws:
org.apache.asn1.codec.DecoderException - if the id cannot be determined due to type limitations of this method's return type.

getTagId

public static final int getTagId(int octets)
Gets the tag id of a TLV from tag octets encoded as a Java primitive int.

Parameters:
octets - the tag octets encoded as a Java primitive int
Returns:
the tag id

getTagId

public static final int getTagId(TagOctetCollector octets)
Gets the tag id of a TLV from the tag octets.

Parameters:
octets - the set of octets needed to determine the tag value (a.k.a identifier octets)
Returns:
the tag id

isPrimitive

public static final boolean isPrimitive(int octet)
Checks to see if the tag is a primitive.

Parameters:
octet - the first octet of the tag
Returns:
true if this tag is of the simple type, false if constructed

isConstructed

public static final boolean isConstructed(int octet)
Checks to see if the tag is constructed.

Parameters:
octet - the first octet of the tag
Returns:
true if constructed, false if primitive

isRawTagConstructed

public static boolean isRawTagConstructed(int rawTag)


Copyright © 2004-2009 . All Rights Reserved.