cryptix.asn1.lang
Class Tag

java.lang.Object
  |
  +--cryptix.asn1.lang.Tag

public class Tag
extends java.lang.Object

A class to handle ASN.1 Tag elements.

Copyright ©1997, 1998, 1999 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.3 $

Author:
Raif S. Naffah, Eric Rescorla

Field Summary
static int APPLICATION
           
static int BIT_STRING
           
static int BOOLEAN
           
(package private)  int clazz
           
(package private)  boolean constructed
           
static int CONTEXT
           
(package private)  boolean explicit
           
static int IA5_STRING
           
static int INTEGER
           
static int NULL
           
static int OBJECT_IDENTIFIER
           
static int OCTET_STRING
           
static int PRINT_STRING
           
static int PRIVATE
           
static int SEQUENCE
           
static int SEQUENCE_OF
           
static int SET
           
static int SET_OF
           
static int T61_STRING
           
static int UNIVERSAL
           
static int UTC_TIME
           
(package private)  int value
           
 
Constructor Summary
(package private) Tag(int value, boolean explicit)
          Convenience constructor.
(package private) Tag(int clazz, int value, boolean explicit)
          Convenience constructor.
(package private) Tag(int clazz, int value, boolean explicit, boolean constructed)
          Constructs an ASN.1 Tag instance.
 
Method Summary
static Tag decode(java.io.InputStream in)
          Constructs a Tag instance from the designated input stream.
 int getClazz()
          Returns the tag's class.
static Tag getExpectedTag(int expectedValue, java.io.InputStream in)
          Convenience method similar to the method with same name and 3 arguments, except it assumes that the tag's class is UNIVERSAL.
static Tag getExpectedTag(int expectedClass, int expectedValue, java.io.InputStream in)
          Returns the tag element of an ASN.1 object if it is of the designated expected class and type, or null otherwise.
static Tag getExpectedTag(Tag tag, java.io.InputStream in)
          Convenience method similar to the method with same name and 3 arguments, except it uses the given tag's class and value.
static byte[] getTag(java.io.InputStream in)
          Get a tag off the wire as a byte[]
 int getValue()
          Returns the tag's class number.
 boolean isConstructed()
          Returns true if the tag is constructed false otherwise.
 boolean isExplicit()
          Returns true if the tag is explicit, false otherwise.
static Tag peek(java.io.InputStream in)
          Returns the Tag instance parsed from the given input stream, if one is there, without modifying the stram marker.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNIVERSAL

public static final int UNIVERSAL

APPLICATION

public static final int APPLICATION

CONTEXT

public static final int CONTEXT

PRIVATE

public static final int PRIVATE

BOOLEAN

public static final int BOOLEAN

INTEGER

public static final int INTEGER

BIT_STRING

public static final int BIT_STRING

OCTET_STRING

public static final int OCTET_STRING

NULL

public static final int NULL

OBJECT_IDENTIFIER

public static final int OBJECT_IDENTIFIER

SEQUENCE

public static final int SEQUENCE

SEQUENCE_OF

public static final int SEQUENCE_OF

SET

public static final int SET

SET_OF

public static final int SET_OF

PRINT_STRING

public static final int PRINT_STRING

T61_STRING

public static final int T61_STRING

IA5_STRING

public static final int IA5_STRING

UTC_TIME

public static final int UTC_TIME

clazz

int clazz

value

int value

explicit

boolean explicit

constructed

boolean constructed
Constructor Detail

Tag

Tag(int clazz,
    int value,
    boolean explicit,
    boolean constructed)
Constructs an ASN.1 Tag instance.
Parameters:
clazz - The tag's class, default is UNIVERSAL.
value - The tag's value.
explicit - Whether this tag is explicit or implicit.
constructed - Whether this tag is constructed or not. Default is not constrcuted.

Tag

Tag(int clazz,
    int value,
    boolean explicit)
Convenience constructor. Constructs an ASN.1 Tag instance.
Parameters:
clazz - The tag's class, default is UNIVERSAL.
value - The tag's value.
explicit - Whether this tag is explicit or implicit.

Tag

Tag(int value,
    boolean explicit)
Convenience constructor. Constructs an ASN.1 Tag instance.
Parameters:
value - The tag's value.
explicit - Whether this tag is explicit or implicit.
Method Detail

getClazz

public int getClazz()
Returns the tag's class.

getValue

public int getValue()
Returns the tag's class number.

isExplicit

public boolean isExplicit()
Returns true if the tag is explicit, false otherwise.

isConstructed

public boolean isConstructed()
Returns true if the tag is constructed false otherwise.

getExpectedTag

public static Tag getExpectedTag(int expectedClass,
                                 int expectedValue,
                                 java.io.InputStream in)
                          throws java.io.IOException
Returns the tag element of an ASN.1 object if it is of the designated expected class and type, or null otherwise. If the stream does not contain the expected tag (of given type) this method ensures that the stream marker is not modified.
Parameters:
expectedClass - The tag's class expected to be found at the current marker location of the given input stream.
expectedValue - The tag's number expected to be found at the current marker location of the given input stream.
in - The input source stream.
Returns:
An instance of the Tag class containing the concrete Tag instance found in the input stream.

getExpectedTag

public static Tag getExpectedTag(int expectedValue,
                                 java.io.InputStream in)
                          throws java.io.IOException
Convenience method similar to the method with same name and 3 arguments, except it assumes that the tag's class is UNIVERSAL.
Parameters:
expectedValue - The tag's number expected to be found at the current marker location of the given input stream.
in - The input source stream.
Returns:
An instance of the Tag class containing the concrete Tag instance found in the input stream.

getExpectedTag

public static Tag getExpectedTag(Tag tag,
                                 java.io.InputStream in)
                          throws java.io.IOException
Convenience method similar to the method with same name and 3 arguments, except it uses the given tag's class and value.
Parameters:
tag - The tag's instance (class and value) expected to be found at the current marker location of the given input stream.
in - The input source stream.
Returns:
An instance of the Tag class containing the concrete Tag instance found in the input stream.

getTag

public static byte[] getTag(java.io.InputStream in)
                     throws java.io.IOException
Get a tag off the wire as a byte[]
Parameters:
in - The input stream
Returns:
a byte with the tag bytes
Throws:
java.io.IOException - --EKR

decode

public static Tag decode(java.io.InputStream in)
                  throws java.io.IOException
Constructs a Tag instance from the designated input stream.
Parameters:
in - The input stream.
Returns:
A Tag instance parsed from an input stream.
Throws:
java.io.IOException - If an error occurs while parsing the input stream.

peek

public static Tag peek(java.io.InputStream in)
                throws java.io.IOException
Returns the Tag instance parsed from the given input stream, if one is there, without modifying the stram marker.
Parameters:
in - The input stream.
Returns:
A Tag instance parsed from the designated input stream.
Throws:
java.io.IOException - If an error occurs while parsing the input stream.

toString

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