public final class

BerEncoder

extends Ber
java.lang.Object
   ↳ com.sun.jndi.ldap.Ber
     ↳ com.sun.jndi.ldap.BerEncoder

Class Overview

A BER encoder.

Summary

[Expand]
Inherited Constants
From class com.sun.jndi.ldap.Ber
[Expand]
Inherited Fields
From class com.sun.jndi.ldap.Ber
Public Constructors
BerEncoder()
Creates a BER buffer for encoding.
BerEncoder(int bufsize)
Creates a BER buffer of a specified size for encoding.
Public Methods
void beginSeq(int tag)
Begin encoding a sequence with a tag.
void encodeBoolean(boolean b)
Encodes a boolean.
void encodeBoolean(boolean b, int tag)
Encodes a boolean and a tag
 BER boolean w TAG ::= tag 0x01 {0xff|0x00}
void encodeByte(int b)
Encode a single byte.
void encodeInt(int i)
void encodeInt(int i, int tag)
Encodes an int and a tag.
void encodeOctetString(byte[] tb, int tag)
Encodes an octet string and a tag.
void encodeOctetString(byte[] tb, int tag, int tboffset, int length)
Encodes a portion of an octet string and a tag.
void encodeString(String str, int tag, boolean encodeUTF8)
Encodes a string and a tag.
void encodeString(String str, boolean encodeUTF8)
Encodes a string.
void encodeStringArray(String[] strs, boolean encodeUTF8)
Encodes an array of strings.
void endSeq()
Terminate a BER sequence.
byte[] getBuf()
Gets the buffer that contains the BER encoding.
int getDataLen()
Gets the number of encoded bytes in this BER buffer.
byte[] getTrimmedBuf()
Gets the buffer that contains the BER encoding, trimming unused bytes.
void reset()
Resets encoder to state when newly constructed.
[Expand]
Inherited Methods
From class com.sun.jndi.ldap.Ber
From class java.lang.Object

Public Constructors

public BerEncoder ()

Creates a BER buffer for encoding.

public BerEncoder (int bufsize)

Creates a BER buffer of a specified size for encoding. Specify the initial bufsize. Buffer will be expanded as needed.

Parameters
bufsize The number of bytes for the buffer.

Public Methods

public void beginSeq (int tag)

Begin encoding a sequence with a tag.

public void encodeBoolean (boolean b)

Encodes a boolean.

 BER boolean ::= 0x01 0x01 {0xff|0x00}

public void encodeBoolean (boolean b, int tag)

Encodes a boolean and a tag

 BER boolean w TAG ::= tag 0x01 {0xff|0x00}

public void encodeByte (int b)

Encode a single byte.

public void encodeInt (int i)

public void encodeInt (int i, int tag)

Encodes an int and a tag.

 BER integer w tag ::= tag berlength byte {byte}*

public void encodeOctetString (byte[] tb, int tag)

Encodes an octet string and a tag.

Throws
Ber.EncodeException

public void encodeOctetString (byte[] tb, int tag, int tboffset, int length)

Encodes a portion of an octet string and a tag.

Throws
Ber.EncodeException

public void encodeString (String str, int tag, boolean encodeUTF8)

Encodes a string and a tag.

 BER string w TAG ::= tag strlen byte1 byte2...

Throws
Ber.EncodeException

public void encodeString (String str, boolean encodeUTF8)

Encodes a string.

 BER string ::= 0x04 strlen byte1 byte2...
The string is converted into bytes using UTF-8 or ISO-Latin-1.

Throws
Ber.EncodeException

public void encodeStringArray (String[] strs, boolean encodeUTF8)

Encodes an array of strings.

Throws
Ber.EncodeException

public void endSeq ()

Terminate a BER sequence.

Throws
Ber.EncodeException

public byte[] getBuf ()

Gets the buffer that contains the BER encoding. Throws an exception if unmatched beginSeq() and endSeq() pairs were encountered. Not entire buffer contains encoded bytes. Use getDataLen() to determine number of encoded bytes. Use getBuffer(true) to get rid of excess bytes in array.

Throws
IllegalStateException If buffer contains unbalanced sequence.

public int getDataLen ()

Gets the number of encoded bytes in this BER buffer.

public byte[] getTrimmedBuf ()

Gets the buffer that contains the BER encoding, trimming unused bytes.

Throws
IllegalStateException If buffer contains unbalanced sequence.

public void reset ()

Resets encoder to state when newly constructed. Zeros out internal data structures.