net.lag.jaramiko.ber
Class Tag

java.lang.Object
  extended by net.lag.jaramiko.ber.Tag

public class Tag
extends java.lang.Object

The header of an ASN.1 object. This includes the class (universal, application, context, or private), the type (any integer), and size.


Field Summary
static int APPLICATION
           
static int CONTEXT
           
static int PRIVATE
           
static Tag TERMINATOR
           
static int UNIVERSAL
           
 
Method Summary
 Tag asSize(int size)
          Return a tag of the same domain & type as this one, but with a different value in the size field.
static Tag create(int domain, int type)
           
static Tag create(int domain, int type, int size)
           
static Tag createContainer(int domain, int type)
           
static Tag createContainer(int domain, int type, int size)
           
 boolean equals(java.lang.Object obj)
           
static Tag fromStream(java.io.InputStream in)
          Read an ASN.1 tag from a stream.
 int getDomain()
           
static java.lang.String getDomainName(int domain)
           
 int getSize()
           
 int getType()
           
 int hashCode()
           
 boolean hasSize()
           
 boolean isContainer()
           
 java.lang.String toString()
           
 void write(java.io.OutputStream out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNIVERSAL

public static final int UNIVERSAL
See Also:
Constant Field Values

APPLICATION

public static final int APPLICATION
See Also:
Constant Field Values

CONTEXT

public static final int CONTEXT
See Also:
Constant Field Values

PRIVATE

public static final int PRIVATE
See Also:
Constant Field Values

TERMINATOR

public static final Tag TERMINATOR
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

create

public static Tag create(int domain,
                         int type)

create

public static Tag create(int domain,
                         int type,
                         int size)

createContainer

public static Tag createContainer(int domain,
                                  int type)

createContainer

public static Tag createContainer(int domain,
                                  int type,
                                  int size)

asSize

public Tag asSize(int size)
Return a tag of the same domain & type as this one, but with a different value in the size field. This is useful for making a prototype Tag with all the fields specified, and using it to generate tags of various sizes for writing to streams.

Parameters:
size - the new size value
Returns:
a new Tag, just like this one, but with the specified size

fromStream

public static Tag fromStream(java.io.InputStream in)
                      throws java.io.IOException
Read an ASN.1 tag from a stream. This simple implementation limits tag types to 28 bits and size fields to 31 bits, but does support container tags and indefinite-length. If a tag is truncated, an IOException is thrown, but if an EOF occurs before reading any of the tag data, null is returned.

After reading a valid tag and returning it, the stream will be positioned at the first byte after the tag. This will either be the tag's content, or if the size is zero, the beginning of the next tag or EOF.

Parameters:
in - the stream to read from
Returns:
a new Tag read from the stream, or null on EOF
Throws:
java.io.IOException - if an IOException occurred or the tag was truncated

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Throws:
java.io.IOException

getDomain

public int getDomain()

getType

public int getType()

getSize

public int getSize()

isContainer

public boolean isContainer()

hasSize

public boolean hasSize()

getDomainName

public static java.lang.String getDomainName(int domain)