codec.asn1
Interface ASN1Type

All Known Subinterfaces:
ASN1Collection, ASN1CollectionOf, ASN1RegisteredType, ASN1String
All Known Implementing Classes:
ASN1AbstractType, ASN1NOP, CRLEntry, X509Crl, X509Certificate

public interface ASN1Type

The basic interface for Java objects representing primitive ASN.1 types according to ITU-T Recommendation X.680. A special feature are constraints. With constraints the range of valid values of an ASN.1 type can be limited. Constraints are validated for most types in the setter methods allowing initialization with Java types.

An abstract implementation of most of the methods declared in this interface can be found in ASN1AbstractType.

Version:
"$Id: ASN1Type.java,v 1.2 2000/12/06 17:47:26 vroth Exp $"
Author:
Volker Roth

Method Summary
 void checkConstraints()
          Checks the constraints registered with this instance.
 void decode(Decoder dec)
           
 void encode(Encoder enc)
           
 Constraint getConstraint()
          Returns the Constraint of this type or null if there is none.
 int getTag()
           
 int getTagClass()
           
 Object getValue()
           
 boolean isExplicit()
           
 boolean isOptional()
           
 boolean isType(int tag, int tagclass)
          Returns true if this type matches the given tag and tagclass.
 void setConstraint(Constraint o)
          Sets a constraint for this type.
 void setExplicit(boolean explicit)
           
 void setOptional(boolean optional)
           
 

Method Detail

getValue

public Object getValue()

setOptional

public void setOptional(boolean optional)

isOptional

public boolean isOptional()

getTag

public int getTag()

getTagClass

public int getTagClass()

setExplicit

public void setExplicit(boolean explicit)

isExplicit

public boolean isExplicit()

isType

public boolean isType(int tag,
                      int tagclass)
Returns true if this type matches the given tag and tagclass. This method is primarily used by decoders in order to verify the tag and tag class of a decoded type. Basic types need not implement this method since ASN1AbstractType provides a default implementation. Certain variable types such as ASN1Choice and ASN1OpenType implement this method. This helps decoders to determine if a decoded type matches a given ASN.1 structure.
Parameters:
tag - The tag to match.
tagclass - The tag class to match.
Returns:
true if this type matches the given tag and tag class.

encode

public void encode(Encoder enc)
            throws ASN1Exception,
                   IOException

decode

public void decode(Decoder dec)
            throws ASN1Exception,
                   IOException

setConstraint

public void setConstraint(Constraint o)
Sets a constraint for this type. Constraints are checked by setter methods and as the last operation of a call to the decode() method. A number of constraints can be defined in ASN.1; one example is the SIZE constraint on string types. For instance, foo IA5String (SIZE 10..20) means the string foo can be 10 to 20 characters long. Strings can also be constrained with regard to the character sets. The constraint model of this package allows to add arbitrary constraints on types.

Parameters:
o - The constraint to set.

getConstraint

public Constraint getConstraint()
Returns the Constraint of this type or null if there is none.
Returns:
The Constraint or null.

checkConstraints

public void checkConstraints()
                      throws ConstraintException
Checks the constraints registered with this instance.
See Also:
Constraint, ConstraintCollection


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.