|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--codec.asn1.ASN1AbstractType
|
+--codec.asn1.ASN1OpenType
This type represents what was formerly called the ASN.1 ANY type. The ANY and
ANY DEFINED BY types are superseded as of ITU-T Recommendation X.680 version
current December 1997 by the ability to define type classes. Modelling type
classes is beyond the scope of this ASN.1 package although the package can be
enhanced accordingly. ASN.1 type classes can contain components whose type is
unspecified. Such components are called "open types". This class
mimics an open type insofar as it decodes any type encountered in an encoded
stream of ASN.1 types. On encoding the proper type is encoded in place of the
open type. Decoding an open type that was not properly initialized either by
a call to a creator with an argument or by decoding it from a valid ASN.1
encoding results in an ASN1Null being decoded.
This class enforces as an invariant that inner types have the same tagging as the type itself. For instance:
ASN1OpenType ot;
ASN1Integer n;
n = new Integer("42");
n.setExplicit(true);
ot = new OpenType(new FooResolver());
ot.setExplicit(false);
ot.setInnerType(n);
will cause the tagging method of n to be changed
into EXPLICIT upon the call to ot.setInnerType().
| Field Summary | |
protected Resolver |
resolver_
|
| Constructor Summary | |
ASN1OpenType()
|
|
ASN1OpenType(ASN1ObjectIdentifier oid)
|
|
ASN1OpenType(OIDRegistry registry,
ASN1ObjectIdentifier oid)
This constructor corresponds to the superseded ANY DEFINED BY type. |
|
ASN1OpenType(Resolver resolver)
Creates an instance that attempts to resolve the actual type on decoding using the given Resolver. |
|
| Method Summary | |
void |
checkConstraints()
Checks the constraint on the inner type if it is set. |
void |
decode(Decoder dec)
Decodes the inner type to the given decoder. |
void |
encode(Encoder enc)
Encodes the inner typeof this open type using the given Encoder. |
ASN1Type |
getInnerType()
Returns the inner ASN.1 type. |
int |
getTag()
Returns the tag of the inner type. |
int |
getTagClass()
Returns the tag class of the inner type. |
Object |
getValue()
Returns the value of the inner type. |
boolean |
isType(int tag,
int tagclass)
This method compares the given tag and tag class with the tag and tag class of the resolved type. |
void |
setConstraint(Constraint constraint)
Sets the Constraint of the inner type. |
void |
setExplicit(boolean explicit)
Sets the tagging to either EXPLICIT or IMPLICIT. |
protected void |
setInnerType(ASN1Type t)
Sets the inner type. |
String |
toString()
Returns the string representation of this instance. |
| Methods inherited from class codec.asn1.ASN1AbstractType |
getConstraint, isExplicit, isOptional, readExternal, setOptional, writeExternal |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Resolver resolver_
| Constructor Detail |
public ASN1OpenType()
public ASN1OpenType(Resolver resolver)
Resolver.resolver - The instance that is asked to deliver the type to decode.
public ASN1OpenType(OIDRegistry registry,
ASN1ObjectIdentifier oid)
oid - The OID that is passed to the given registry on resolving.public ASN1OpenType(ASN1ObjectIdentifier oid)
| Method Detail |
public ASN1Type getInnerType()
throws ResolverException
Resolver is set then the Resolver is asked to resolve
the inner type. The resulting type is then returned.
This method may return null if the resolver cannot
determine the inner type of the open type. In particular, if the Resolver
is null and no inner type is already set then
null is returned.
protected void setInnerType(ASN1Type t)
t - The type to set as the inner type.NullPointerException - if the given type is null.public int getTag()
getTag in class ASN1AbstractTypeIllegalStateException - if the inner type is not yet initialized.public int getTagClass()
getTagClass in class ASN1AbstractTypeIllegalStateException - if the inner type is not yet initialized.public Object getValue()
ASN1Null. This method calls
getValue on the inner type and returns the
result.getValue in class ASN1AbstractTypeIllegalStateException - if the inner type is not yet initialized.public void setExplicit(boolean explicit)
setExplicit in class ASN1AbstractTypeexplicit - true if this type shall be tagged EXPLICIT
and false if it shall be encoded IMPLICIT.IllegalStateException - if the inner type is not yet initialized.public void setConstraint(Constraint constraint)
Constraint of the inner type. For instance an
ASN.1 INTEGER might be constrained to a certain range such as INTEGER
(0..99). null can be passed as a constraint which disables
constraint checking.setConstraint in class ASN1AbstractTypeconstraint - The Constraint of this type.IllegalStateException - if the inner type is not yet initialized.
public void checkConstraints()
throws ConstraintException
checkConstraints in class ASN1AbstractTypeConstraintException - if this type is not in the appropriate range of values.IllegalStateException - if the inner type is not yet initialized.
public boolean isType(int tag,
int tagclass)
If an exception is thrown by the Resolver upon resolving
the inner type of this type then false is returned in
order to provoke a decoding error.
If no inner type can be resolved then true
is returned. In
that case this type behaves like the ANY type known from previous ASN.1
versions.
isType in class ASN1AbstractTypetag - The tag to match.tagclass - The tag class to match.true iff the given tag and tag class match one of
the alternative types represented by this variable type.
public void encode(Encoder enc)
throws ASN1Exception,
IOException
Encoder. If the inner type is not yet initialized then
an exception is thrown.encode in class ASN1AbstractTypeenc - The Encoder to use for encoding the inner
type.IllegalStateException - if the inner type is not yet initialized.
public void decode(Decoder dec)
throws ASN1Exception,
IOException
decoder. If a
resolver was specified then it is asked to provide an
ASN.1 type to decode.decode in class ASN1AbstractTypedec - The decoder to decode to.IllegalStateException - if the open type cannot be resolved on runtime.public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||