|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.demac.impl.j2me.process.base.service.webservices.asn1.ASN1AbstractType
org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1OpenType
public class 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:
will cause the tagging method ofASN1OpenType ot; ASN1Integer n; n = new Integer("42"); n.setExplicit(true); ot = new OpenType(new FooResolver()); ot.setExplicit(false); ot.setInnerType(n);
n
to be changed
into EXPLICIT upon the call to ot.setInnerType()
.
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. |
java.lang.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. |
java.lang.String |
toString()
Returns the string representation of this instance. |
Methods inherited from class org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1AbstractType |
---|
getConstraint, isExplicit, isOptional, readExternal, setOptional, writeExternal |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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.
ResolverException
public int getTag()
getTag
in interface ASN1Type
getTag
in class ASN1AbstractType
java.lang.IllegalStateException
- if the inner type is not yet initialized.public int getTagClass()
getTagClass
in interface ASN1Type
getTagClass
in class ASN1AbstractType
java.lang.IllegalStateException
- if the inner type is not yet initialized.public java.lang.Object getValue()
ASN1Null
. This method calls
getValue
on the inner type and returns the
result.
getValue
in interface ASN1Type
getValue
in class ASN1AbstractType
java.lang.IllegalStateException
- if the inner type is not yet initialized.public void setExplicit(boolean explicit)
setExplicit
in interface ASN1Type
setExplicit
in class ASN1AbstractType
explicit
- true
if this type shall be tagged EXPLICIT
and false
if it shall be encoded IMPLICIT.
java.lang.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 interface ASN1Type
setConstraint
in class ASN1AbstractType
constraint
- The Constraint
of this type.
java.lang.IllegalStateException
- if the inner type is not yet initialized.public void checkConstraints() throws ConstraintException
checkConstraints
in interface ASN1Type
checkConstraints
in class ASN1AbstractType
ConstraintException
- if this type is not in the appropriate range of values.
java.lang.IllegalStateException
- if the inner type is not yet initialized.Constraint
,
ConstraintCollection
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 interface ASN1Type
isType
in class ASN1AbstractType
tag
- 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, java.io.IOException
Encoder
. If the inner type is not yet initialized then
an exception is thrown.
encode
in interface ASN1Type
encode
in class ASN1AbstractType
enc
- The Encoder
to use for encoding the inner
type.
java.lang.IllegalStateException
- if the inner type is not yet initialized.
ASN1Exception
java.io.IOException
public void decode(Decoder dec) throws ASN1Exception, java.io.IOException
decoder
. If a
resolver
was specified then it is asked to provide an
ASN.1 type to decode.
decode
in interface ASN1Type
decode
in class ASN1AbstractType
dec
- The decoder to decode to.
java.lang.IllegalStateException
- if the open type cannot be resolved on runtime.
ASN1Exception
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |