netscape.ldap.ber.stream

Class BERElement

Implemented Interfaces:
Serializable
Known Direct Subclasses:
BERAny, BERBitString, BERBoolean, BERCharacterString, BERChoice, BERConstruct, BERIntegral, BERNull, BERObjectId, BEROctetString, BERReal, BERTag, BERUTCTime

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

This class is for the tagged object type. A nested tag is allowed. A tagged element contains another BER element.
Version:
1.0 seeAlso CCITT X.209

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

Method Summary

String
byteToHexString(byte value)
Converts byte to hex string.
static BERElement
getElement(BERTagDecoder decoder, InputStream stream, int[] bytes_read)
Gets a ber element from the input stream.
abstract int
getType()
Gets the element type.
static int
readLengthOctets(InputStream stream, int[] bytes_read)
Reads and decodes a length byte and then that many octets from the input stream.
protected int
readTwosComplement(InputStream stream, int[] bytes_read, int length)
Reads the two's complement representation of an integer from an input stream.
protected int
readUnsignedBinary(InputStream stream, int[] bytes_read, int length)
Reads a number of bytes from an input stream and form an integer..
static void
sendDefiniteLength(OutputStream stream, int num_content_octets)
Writes length octets (definite length only) to stream.
abstract String
toString()
Gets the string representation.
abstract void
write(OutputStream stream)
Sends the BER encoding directly to a stream.

Field Details

ANY

public static final int ANY
Field Value:
-3

APPLICATION

public static final int APPLICATION
Field Value:
64

BITSTRING

public static final int BITSTRING
Field Value:
3

BOOLEAN

public static final int BOOLEAN
Possible element types.
Field Value:
1

CHOICE

public static final int CHOICE
Field Value:
-2

CONSTRUCTED

public static final int CONSTRUCTED
Field Value:
32

CONTEXT

public static final int CONTEXT
Field Value:
128

ENUMERATED

public static final int ENUMERATED
Field Value:
10

EOC

public static final int EOC
Possible tags.
Field Value:
0

EXOP_REQ_OID

public static final int EXOP_REQ_OID
Field Value:
0

EXOP_REQ_VALUE

public static final int EXOP_REQ_VALUE
Field Value:
1

EXOP_RES_OID

public static final int EXOP_RES_OID
Field Value:
10

EXOP_RES_VALUE

public static final int EXOP_RES_VALUE
Field Value:
11

GENERALSTRING

public static final int GENERALSTRING
Field Value:
27

GRAPHICSTRING

public static final int GRAPHICSTRING
Field Value:
25

IA5STRING

public static final int IA5STRING
Field Value:
22

INTEGER

public static final int INTEGER
Field Value:
2

MRA_DNATTRS

public static final int MRA_DNATTRS
Field Value:
4

MRA_OID

public static final int MRA_OID
Field Value:
1

MRA_TYPE

public static final int MRA_TYPE
Field Value:
2

MRA_VALUE

public static final int MRA_VALUE
Field Value:
3

NULL

public static final int NULL
Field Value:
5

NUMERICSTRING

public static final int NUMERICSTRING
Field Value:
18

OBJECTID

public static final int OBJECTID
Field Value:
6

OCTETSTRING

public static final int OCTETSTRING
Field Value:
4

PRIMITIVE

public static final int PRIMITIVE
Field Value:
0

PRINTABLESTRING

public static final int PRINTABLESTRING
Field Value:
19

PRIVATE

public static final int PRIVATE
Field Value:
192

REAL

public static final int REAL
Field Value:
9

SASLCONTEXT

public static final int SASLCONTEXT
Field Value:
160

SEQUENCE

public static final int SEQUENCE
Field Value:
48

SET

public static final int SET
Field Value:
49

SK_MATCHRULE

public static final int SK_MATCHRULE
Field Value:
0

SK_REVERSE

public static final int SK_REVERSE
Field Value:
1

SR_ATTRTYPE

public static final int SR_ATTRTYPE
Field Value:
0

TAG

public static final int TAG
Internal (non-transmitted) tags.
Field Value:
-1

TELETEXSTRING

public static final int TELETEXSTRING
Field Value:
20

UNIVERSAL

public static final int UNIVERSAL
Field Value:
0

UTCTIME

public static final int UTCTIME
Field Value:
23

VIDEOTEXSTRING

public static final int VIDEOTEXSTRING
Field Value:
21

VISIBLESTRING

public static final int VISIBLESTRING
Field Value:
26

Method Details

byteToHexString

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

getElement

public static BERElement getElement(BERTagDecoder decoder,
                                    InputStream stream,
                                    int[] bytes_read)
            throws 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

getType

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

readLengthOctets

public static int readLengthOctets(InputStream stream,
                                   int[] bytes_read)
            throws 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.

readTwosComplement

protected int readTwosComplement(InputStream stream,
                                 int[] bytes_read,
                                 int length)
            throws 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.

readUnsignedBinary

protected int readUnsignedBinary(InputStream stream,
                                 int[] bytes_read,
                                 int length)
            throws 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.

sendDefiniteLength

public static void sendDefiniteLength(OutputStream stream,
                                      int num_content_octets)
            throws 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

toString

public abstract String toString()
Gets the string representation.
Returns:
string representation of an element.

write

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