netscape.ldap.ber.stream
Class BERElement

java.lang.Object
  |
  +--netscape.ldap.ber.stream.BERElement
Direct Known Subclasses:
BERAny, BERBitString, BERBoolean, BERCharacterString, BERChoice, BERConstruct, BERIntegral, BERNull, BERObjectId, BEROctetString, BERReal, BERTag, BERUTCTime

public abstract class BERElement
extends java.lang.Object
implements java.io.Serializable

This class is for the tagged object type. A nested tag is allowed. A tagged element contains another BER element.

See Also:
Serialized Form

Field Summary
static int ANY
           
static int APPLICATION
           
static int BITSTRING
           
static int BOOLEAN
          Possible element types.
static int CHOICE
           
static int CONSTRUCTED
           
static int CONTEXT
           
static int ENUMERATED
           
static int EOC
          Possible tags.
static int EXOP_REQ_OID
           
static int EXOP_REQ_VALUE
           
static int EXOP_RES_OID
           
static int EXOP_RES_VALUE
           
static int GENERALSTRING
           
static int GRAPHICSTRING
           
static int IA5STRING
           
static int INTEGER
           
static int MRA_DNATTRS
           
static int MRA_OID
           
static int MRA_TYPE
           
static int MRA_VALUE
           
static int NULL
           
static int NUMERICSTRING
           
static int OBJECTID
           
static int OCTETSTRING
           
static int PRIMITIVE
           
static int PRINTABLESTRING
           
static int PRIVATE
           
static int REAL
           
static int SASLCONTEXT
           
static int SEQUENCE
           
static int SET
           
static int SK_MATCHRULE
           
static int SK_REVERSE
           
static int SR_ATTRTYPE
           
static int TAG
          Internal (non-transmitted) tags.
static int TELETEXSTRING
           
static int UNIVERSAL
           
static int UTCTIME
           
static int VIDEOTEXSTRING
           
static int VISIBLESTRING
           
 
Constructor Summary
BERElement()
           
 
Method Summary
 java.lang.String byteToHexString(byte value)
          Converts byte to hex string.
static BERElement getElement(BERTagDecoder decoder, java.io.InputStream stream, int[] bytes_read)
          Gets a ber element from the input stream.
abstract  int getType()
          Gets the element type.
static int readLengthOctets(java.io.InputStream stream, int[] bytes_read)
          Reads and decodes a length byte and then that many octets from the input stream.
protected  int readTwosComplement(java.io.InputStream stream, int[] bytes_read, int length)
          Reads the two's complement representation of an integer from an input stream.
protected  int readUnsignedBinary(java.io.InputStream stream, int[] bytes_read, int length)
          Reads a number of bytes from an input stream and form an integer..
static void sendDefiniteLength(java.io.OutputStream stream, int num_content_octets)
          Writes length octets (definite length only) to stream.
abstract  java.lang.String toString()
          Gets the string representation.
abstract  void write(java.io.OutputStream stream)
          Sends the BER encoding directly to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOOLEAN

public static final int BOOLEAN
Possible element types.

INTEGER

public static final int INTEGER

BITSTRING

public static final int BITSTRING

OCTETSTRING

public static final int OCTETSTRING

NULL

public static final int NULL

OBJECTID

public static final int OBJECTID

REAL

public static final int REAL

ENUMERATED

public static final int ENUMERATED

SET

public static final int SET

SEQUENCE

public static final int SEQUENCE

NUMERICSTRING

public static final int NUMERICSTRING

PRINTABLESTRING

public static final int PRINTABLESTRING

TELETEXSTRING

public static final int TELETEXSTRING

VIDEOTEXSTRING

public static final int VIDEOTEXSTRING

IA5STRING

public static final int IA5STRING

UTCTIME

public static final int UTCTIME

GRAPHICSTRING

public static final int GRAPHICSTRING

VISIBLESTRING

public static final int VISIBLESTRING

GENERALSTRING

public static final int GENERALSTRING

TAG

public static final int TAG
Internal (non-transmitted) tags.

CHOICE

public static final int CHOICE

ANY

public static final int ANY

EOC

public static final int EOC
Possible tags.

UNIVERSAL

public static final int UNIVERSAL

APPLICATION

public static final int APPLICATION

CONTEXT

public static final int CONTEXT

SASLCONTEXT

public static final int SASLCONTEXT

PRIVATE

public static final int PRIVATE

PRIMITIVE

public static final int PRIMITIVE

CONSTRUCTED

public static final int CONSTRUCTED

MRA_OID

public static final int MRA_OID

MRA_TYPE

public static final int MRA_TYPE

MRA_VALUE

public static final int MRA_VALUE

MRA_DNATTRS

public static final int MRA_DNATTRS

EXOP_REQ_OID

public static final int EXOP_REQ_OID

EXOP_REQ_VALUE

public static final int EXOP_REQ_VALUE

EXOP_RES_OID

public static final int EXOP_RES_OID

EXOP_RES_VALUE

public static final int EXOP_RES_VALUE

SK_MATCHRULE

public static final int SK_MATCHRULE

SK_REVERSE

public static final int SK_REVERSE

SR_ATTRTYPE

public static final int SR_ATTRTYPE
Constructor Detail

BERElement

public BERElement()
Method Detail

getElement

public static BERElement getElement(BERTagDecoder decoder,
                                    java.io.InputStream stream,
                                    int[] bytes_read)
                             throws java.io.IOException
Gets a ber element from the input stream.
Parameters:
decoder - decoder for application specific BER
stream - source of ber encoding
bytes_read - array of 1 int; value incremented by number of bytes read from stream
Throws:
java.io.IOException - failed to decode an element.

readLengthOctets

public static int readLengthOctets(java.io.InputStream stream,
                                   int[] bytes_read)
                            throws java.io.IOException
Reads and decodes a length byte and then that many octets from the input stream.
Parameters:
stream - input stream from which to read
bytes_read - array of 1 int; value incremented by number of bytes read from stream
Returns:
length of contents or -1 if indefinite length.
Throws:
java.io.IOException - failed to read octets

sendDefiniteLength

public static void sendDefiniteLength(java.io.OutputStream stream,
                                      int num_content_octets)
                               throws java.io.IOException
Writes length octets (definite length only) to stream. Uses shortform whenever possible.
Parameters:
stream - output stream to write to
num_content_octets - value to be encode into length octets
Returns:
number of bytes sent to stream.
Throws:
java.io.IOException - failed to read octets

readUnsignedBinary

protected int readUnsignedBinary(java.io.InputStream stream,
                                 int[] bytes_read,
                                 int length)
                          throws java.io.IOException
Reads a number of bytes from an input stream and form an integer..
Parameters:
stream - source of data
bytes_read - number of bytes read
length - number of bytes to be read (1 to 4)
Returns:
the value of the data as two's complement.
Throws:
java.io.IOException - failed to read octets

readTwosComplement

protected int readTwosComplement(java.io.InputStream stream,
                                 int[] bytes_read,
                                 int length)
                          throws java.io.IOException
Reads the two's complement representation of an integer from an input stream.
Parameters:
stream - source of data
bytes_read - number of bytes read
length - number of bytes to be read
Returns:
the integer value as two's complement.
Throws:
java.io.IOException - failed to read octets

byteToHexString

public java.lang.String byteToHexString(byte value)
Converts byte to hex string.
Parameters:
value - byte value
Returns:
string representation of Hex String

write

public abstract void write(java.io.OutputStream stream)
                    throws java.io.IOException
Sends the BER encoding directly to a stream.
Parameters:
stream - output stream
Returns:
bytes written to stream.

getType

public abstract int getType()
Gets the element type.
Returns:
element type.

toString

public abstract java.lang.String toString()
Gets the string representation.
Overrides:
toString in class java.lang.Object
Returns:
string representation of an element.