codec.asn1
Class ASN1TaggedType

java.lang.Object
  |
  +--codec.asn1.ASN1AbstractType
        |
        +--codec.asn1.ASN1TaggedType
All Implemented Interfaces:
ASN1Type, Cloneable, Externalizable, Serializable
Direct Known Subclasses:
ASN1Opaque

public class ASN1TaggedType
extends ASN1AbstractType

Represents an ASN.1 tagged type. Tagged types are types that modify the tag of an underlying type. The ASN.1 type classes CONTEXT, PRIVATE, and APPLICATION specify tagged types.

Version:
"$Id: ASN1TaggedType.java,v 1.4 2004/08/09 07:45:30 flautens Exp $"
Author:
Volker Roth
See Also:
Serialized Form

Constructor Summary
ASN1TaggedType(int tag, ASN1Type inner, boolean explicit)
          Creates an instance with the given tag and inner type.
ASN1TaggedType(int tag, ASN1Type inner, boolean explicit, boolean optional)
          Creates an instance with the given tag, tag class, and inner type.
ASN1TaggedType(int tag, int cls, ASN1Type inner, boolean explicit)
          Creates an instance with the given tag, tag class, and inner type.
 
Method Summary
 void decode(Decoder dec)
           
 void encode(Encoder enc)
           
 ASN1Type getInnerType()
          Returns the underlying ASN.1 type.
 int getTag()
          Returns the tag of this type.
 int getTagClass()
          Returns the tag class of this type.
 Object getValue()
          Returns the value of the inner type.
 boolean isExplicit()
          Tagged types themselves are always tagged EXPLICIT.
 void setExplicit(boolean explicit)
          Throws an exception if the give tagging type is not EXPLICIT (true).
 void setInnerType(ASN1Type t)
          Sets the inner type of this CONTEXT SPECIFIC type.
 void setTag(int tag)
          Sets the tag of this type.
 void setTagClass(int cls)
          Sets the tag class of this type.
 String toString()
           
 
Methods inherited from class codec.asn1.ASN1AbstractType
checkConstraints, getConstraint, isOptional, isType, readExternal, setConstraint, setOptional, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ASN1TaggedType

public ASN1TaggedType(int tag,
                      int cls,
                      ASN1Type inner,
                      boolean explicit)
Creates an instance with the given tag, tag class, and inner type. The tagging method is EXPLICIT if explicit is true and IMPLICIT otherwise.
Parameters:
tag - The tag of this type.
cls - The tag class of this type, for instance CONTEXT SPECIFIC.
inner - The inner type of this tagged type.
explicit - true if EXPLICIT tagging shall be used and false if the tagging method shall be IMPLICIT.
Throws:
NullPointerException - if the given inner type is null.

ASN1TaggedType

public ASN1TaggedType(int tag,
                      ASN1Type inner,
                      boolean explicit)
Creates an instance with the given tag and inner type. The tagging method is EXPLICIT if explicit is true and IMPLICIT otherwise. The tag class is set to CONTEXT SPECIFIC.
Parameters:
tag - The tag of this type.
inner - The inner type of this tagged type.
explicit - true if EXPLICIT tagging shall be used and false if the tagging method shall be IMPLICIT.
Throws:
NullPointerException - if the given inner type is null.

ASN1TaggedType

public ASN1TaggedType(int tag,
                      ASN1Type inner,
                      boolean explicit,
                      boolean optional)
Creates an instance with the given tag, tag class, and inner type. The tagging method is EXPLICIT if explicit is true and IMPLICIT otherwise. The tag class is set to CONTEXT SPECIFIC. If optional is true then this type is declared OPTIONAL.
Parameters:
tag - The tag of this type.
inner - The inner type of this tagged type.
explicit - true if EXPLICIT tagging shall be used and false if the tagging method shall be IMPLICIT.
optional - true declares this type as OPTIONAL.
Throws:
NullPointerException - if the given inner type is null.
Method Detail

getInnerType

public ASN1Type getInnerType()
Returns the underlying ASN.1 type. Please note that OPTIONAL modifiers of (for instance) context-specific types in compound ASN.1 types refer to the outer type and not to the inner type. Types are declared OPTIONAL by calling their setOptional method.
Returns:
The underlying ASN.1 type.

getValue

public Object getValue()
Returns the value of the inner type. The default inner type is ASN1Null. This method calls getValue on the inner type and returns the result.
Overrides:
getValue in class ASN1AbstractType
Returns:
The value of the inner type.

setInnerType

public void setInnerType(ASN1Type t)
Sets the inner type of this CONTEXT SPECIFIC type.
Parameters:
t - The type to set as the inner type.
Throws:
NullPointerException - if the given type is null.

setTag

public void setTag(int tag)
Sets the tag of this type.
Parameters:
tag - The tag.

getTag

public int getTag()
Returns the tag of this type.
Overrides:
getTag in class ASN1AbstractType
Returns:
The tag of this type.

setTagClass

public void setTagClass(int cls)
Sets the tag class of this type. This tag class may be one of UNIVERSAL, CONTEXT SPECIFIC, PRIVATE, or APPLICATION.
Parameters:
cls - The tag class.

getTagClass

public int getTagClass()
Returns the tag class of this type. The default class of this instance is CONTEXT SPECIFIC.
Overrides:
getTagClass in class ASN1AbstractType
Returns:
The class of this ASN.1 tag.

isExplicit

public boolean isExplicit()
Tagged types themselves are always tagged EXPLICIT. The inner type can be tagged either EXPLICIT or IMPLICIT. IMPLICIT types are isomorphic to the underlying type except that the tag and tag class is distinct (with regard to encoding).
Overrides:
isExplicit in class ASN1AbstractType
Returns:
true, tagged types themselves are always tagged EXPLICIT.

setExplicit

public void setExplicit(boolean explicit)
Throws an exception if the give tagging type is not EXPLICIT (true). Tagged types themselves are always EXPLICIT; re-tagging tagged types is very bad style!
Overrides:
setExplicit in class ASN1AbstractType
Parameters:
explicit - The tagging method of the tagged (outer) type. This should not be mixed with the tagging method of the inner type which can be tagged either EXPLICIT or IMPLICIT.

encode

public void encode(Encoder enc)
            throws ASN1Exception,
                   IOException
Overrides:
encode in class ASN1AbstractType

decode

public void decode(Decoder dec)
            throws ASN1Exception,
                   IOException
Overrides:
decode in class ASN1AbstractType

toString

public String toString()
Overrides:
toString in class Object


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.