org.demac.impl.j2me.process.base.service.webservices.asn1
Class ASN1ObjectIdentifier

java.lang.Object
  extended by org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1AbstractType
      extended by org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1ObjectIdentifier
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, ASN1Type

public class ASN1ObjectIdentifier
extends ASN1AbstractType
implements java.lang.Cloneable, java.lang.Comparable

Represents an ASN.1 OBJECT IDENTIFIER type. The corresponding Java type is int[]. Constraints are checked for this type only at the end of method decode.

See Also:
Serialized Form

Constructor Summary
ASN1ObjectIdentifier()
          Creates a new ASN1ObjectIdentifier object.
ASN1ObjectIdentifier(int[] oid)
          Creates an instance with the given array of integers as elements.
ASN1ObjectIdentifier(java.lang.String s)
          Creates an ASN.1 OBJECT IDENTIFIER instance initialized from the given OID string representation.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this instance.
 int compareTo(java.lang.Object o)
          This method compares two OID and returns -1, 0, 1 if this OID is less than, equal or greater than the given one.
 void decode(Decoder dec)
          Decodes to this ASN1ObjectIdentifier.
 int elementCount()
          Returns the number of elements of the oid.
 void encode(Encoder enc)
          Encodes this ASN1ObjectIdentifier.
 boolean equals(java.lang.Object o)
          Compares two OIDs for equality.
 int[] getOID()
          DOCUMENT ME!
 int getTag()
          DOCUMENT ME!
 java.lang.Object getValue()
          DOCUMENT ME!
 int hashCode()
          This method computes the hash code of this instance.
 boolean isPrefixOf(ASN1ObjectIdentifier o)
          This method determines whether the given OID is part of the OID family defined by this OID prefix.
 void setOID(int[] oid)
          DOCUMENT ME!
 java.lang.String toString()
          Returns the string representation of this OID.
 
Methods inherited from class org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1AbstractType
checkConstraints, getConstraint, getTagClass, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, writeExternal
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ASN1ObjectIdentifier

public ASN1ObjectIdentifier()
Creates a new ASN1ObjectIdentifier object.


ASN1ObjectIdentifier

public ASN1ObjectIdentifier(int[] oid)
Creates an instance with the given array of integers as elements. No constraints are checked by this constructor.

Parameters:
oid - The array of consecutive integers of the OID.
Throws:
java.lang.NullPointerException - if the given oid is null.
java.lang.IllegalArgumentException - if the given oid is not well-formed. For instance, a bad oid might have a value greater than 2 as its first element.

ASN1ObjectIdentifier

public ASN1ObjectIdentifier(java.lang.String s)
                     throws java.lang.NumberFormatException
Creates an ASN.1 OBJECT IDENTIFIER instance initialized from the given OID string representation. The format must be either OID.1.2.3.4, oid.1.2.3.4, or 1.2.3.4 for the initiliser to work properly. Trailing dots are ignored.

Parameters:
s - string representation of oid
Throws:
java.lang.NumberFormatException - if some element of the OID string is not an integer number.
java.lang.IllegalArgumentException - if the string is not a well-formed OID.
Method Detail

getValue

public java.lang.Object getValue()
DOCUMENT ME!

Specified by:
getValue in interface ASN1Type
Specified by:
getValue in class ASN1AbstractType
Returns:
DOCUMENT ME!

getOID

public int[] getOID()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setOID

public void setOID(int[] oid)
            throws ConstraintException
DOCUMENT ME!

Parameters:
oid - DOCUMENT ME!
Throws:
ConstraintException - DOCUMENT ME!

elementCount

public int elementCount()
Returns the number of elements of the oid.

Returns:
the number of elements

getTag

public int getTag()
DOCUMENT ME!

Specified by:
getTag in interface ASN1Type
Specified by:
getTag in class ASN1AbstractType
Returns:
DOCUMENT ME!

encode

public void encode(Encoder enc)
            throws ASN1Exception,
                   java.io.IOException
Encodes this ASN1ObjectIdentifier.

Specified by:
encode in interface ASN1Type
Specified by:
encode in class ASN1AbstractType
Parameters:
enc - The encoder to encode to.
Throws:
ASN1Exception
java.io.IOException

decode

public void decode(Decoder dec)
            throws ASN1Exception,
                   java.io.IOException
Decodes to this ASN1ObjectIdentifier.

Specified by:
decode in interface ASN1Type
Specified by:
decode in class ASN1AbstractType
Parameters:
dec - DOCUMENT ME!
Throws:
ASN1Exception
java.io.IOException

toString

public java.lang.String toString()
Returns the string representation of this OID. The string consists of the numerical elements of the OID separated by periods.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the OID.

equals

public boolean equals(java.lang.Object o)
Compares two OIDs for equality. Two OIDs are equal if the have the same number of elements and all corresponding elements are equal.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object to compare to.
Returns:
true iff the given object is an ASN1ObjectIdentifier and iff it equals this one.

hashCode

public int hashCode()
This method computes the hash code of this instance. The hash code of this instance is defined as a hash function of the underlying integer array.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of this instance.

compareTo

public int compareTo(java.lang.Object o)
This method compares two OID and returns -1, 0, 1 if this OID is less than, equal or greater than the given one. OID are interpreted as strings of numbers. An OID that is a prefix of another is always smaller than the other.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The OID to compare to.
Returns:
-1, 0, 1 if this OID is smaller than, equal to, or greater than the given OID.
Throws:
java.lang.ClassCastException - iff o is not an ASN1ObjectIdentifier.

isPrefixOf

public boolean isPrefixOf(ASN1ObjectIdentifier o)
This method determines whether the given OID is part of the OID family defined by this OID prefix. In other words, this method returns true if this OID is a prefix of the given one.

Parameters:
o - the oid to check
Returns:
true if this OID is a prefix of the given one.

clone

public java.lang.Object clone()
Returns a clone of this instance. This method is not thread safe. The constraints are copied by reference.

Overrides:
clone in class java.lang.Object
Returns:
The clone.