org.opends.server.protocols.asn1
Class ASN1Long

java.lang.Object
  extended by org.opends.server.protocols.asn1.ASN1Element
      extended by org.opends.server.protocols.asn1.ASN1Long
All Implemented Interfaces:
java.io.Serializable, ProtocolElement

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class ASN1Long
extends ASN1Element

This class defines the data structures and methods to use when interacting with ASN.1 integer elements that may need to hold values greater than will fit in the scope of a Java int structure.

Note that the difference between the ASN1Integer and ASN1Long classes is purely artificial. The ASN.1 specification does not define any size limits for integer values, but the ASN1Integer class uses an int data type behind the scenes and therefore is only capable of representing values up to 231 - 1 (a little over two billion). This class uses a long data type behind the scenes and therefore is capable of holding much larger values. Because of the need to deal with larger values, this class may have a small performance disadvantage over the ASN1Integer class and therefore that class should be used for cases in which there is no danger of overflowing an int value.

See Also:
Serialized Form

Constructor Summary
ASN1Long(byte type, long longValue)
          Creates a new ASN.1 long element with the specified type and value.
ASN1Long(long longValue)
          Creates a new ASN.1 long element with the default type and the provided value.
 
Method Summary
static ASN1Long decodeAsLong(ASN1Element element)
          Decodes the provided ASN.1 element as a long element.
static ASN1Long decodeAsLong(byte[] encodedElement)
          Decodes the provided byte array as an ASN.1 long element.
 long longValue()
          Retrieves the long value for this ASN.1 long element.
 void setValue(byte[] value)
          Specifies the value for this ASN.1 long element.
 void setValue(long longValue)
          Specifies the long value for this ASN.1 long element.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this ASN.1 integer element to the provided buffer.
 void toString(java.lang.StringBuilder buffer, int indent)
          Appends a string representation of this protocol element to the provided buffer.
 
Methods inherited from class org.opends.server.protocols.asn1.ASN1Element
decode, decode, decodeAsBoolean, decodeAsEnumerated, decodeAsInteger, decodeAsLong, decodeAsNull, decodeAsOctetString, decodeAsSequence, decodeAsSet, decodeElements, encode, encodeLength, encodeLongValue, encodeValue, encodeValue, encodeValue, equals, equalsElement, equalsIgnoreType, equalsIgnoreType, getProtocolElementName, getType, hashCode, isApplicationSpecific, isConstructed, isContextSpecific, isPrimitive, isPrivate, isUniversal, setType, setValueInternal, toString, value
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ASN1Long

public ASN1Long(long longValue)
Creates a new ASN.1 long element with the default type and the provided value.

Parameters:
longValue - The value for this ASN.1 long element.

ASN1Long

public ASN1Long(byte type,
                long longValue)
Creates a new ASN.1 long element with the specified type and value.

Parameters:
type - The BER type for this ASN.1 long element.
longValue - The value for this ASN.1 long element.
Method Detail

longValue

public long longValue()
Retrieves the long value for this ASN.1 long element.

Returns:
The long value for this ASN.1 long element.

setValue

public void setValue(long longValue)
Specifies the long value for this ASN.1 long element.

Parameters:
longValue - The long value for this ASN.1 long element.

setValue

public void setValue(byte[] value)
              throws ASN1Exception
Specifies the value for this ASN.1 long element.

Overrides:
setValue in class ASN1Element
Parameters:
value - The encoded value for this ASN.1 long element.
Throws:
ASN1Exception - If the provided array is null or is not between one and four bytes in length.

decodeAsLong

public static ASN1Long decodeAsLong(ASN1Element element)
                             throws ASN1Exception
Decodes the provided ASN.1 element as a long element.

Parameters:
element - The ASN.1 element to decode as a long element.
Returns:
The decoded ASN.1 long element.
Throws:
ASN1Exception - If the provided ASN.1 element cannot be decoded as a long element.

decodeAsLong

public static ASN1Long decodeAsLong(byte[] encodedElement)
                             throws ASN1Exception
Decodes the provided byte array as an ASN.1 long element.

Parameters:
encodedElement - The byte array to decode as an ASN.1 long element.
Returns:
The decoded ASN.1 long element.
Throws:
ASN1Exception - If the provided byte array cannot be decoded as an ASN.1 long element.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this ASN.1 integer element to the provided buffer.

Specified by:
toString in interface ProtocolElement
Overrides:
toString in class ASN1Element
Parameters:
buffer - The buffer to which the information should be appended.

toString

public void toString(java.lang.StringBuilder buffer,
                     int indent)
Appends a string representation of this protocol element to the provided buffer.

Specified by:
toString in interface ProtocolElement
Overrides:
toString in class ASN1Element
Parameters:
buffer - The buffer into which the string representation should be written.
indent - The number of spaces that should be used to indent the resulting string representation.