public final class

BerDecoder

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

Class Overview

A BER decoder. Contains methods to parse a BER buffer.

Summary

[Expand]
Inherited Constants
From class com.sun.jndi.ldap.Ber
[Expand]
Inherited Fields
From class com.sun.jndi.ldap.Ber
Public Constructors
BerDecoder(byte[] buf, int offset, int bufsize)
Creates a BER decoder that reads bytes from the specified buffer.
Public Methods
int bytesLeft()
Returns the number of unparsed bytes in this BER buffer.
int getParsePosition()
Returns the current parse position.
boolean parseBoolean()
Parses an ASN_BOOLEAN tagged integer from this BER buffer.
int parseByte()
Parses the next byte in this BER buffer.
int parseEnumeration()
Parses an ASN_ENUMERATED tagged integer from this BER buffer.
int parseInt()
Parses an ASN_INTEGER tagged integer from this BER buffer.
int parseLength()
Parses a possibly variable length field.
byte[] parseOctetString(int tag, int[] rlen)
Parses an octet string of a given type(tag) from this BER buffer.
int parseSeq(int[] rlen)
Parses the next sequence in this BER buffer.
String parseString(boolean decodeUTF8)
Parses a string.
String parseStringWithTag(int tag, boolean decodeUTF8, int[] rlen)
Parses a string of a given tag from this BER buffer.
int peekByte()
Returns the next byte in this BER buffer without consuming it.
void reset()
Resets this decode to start parsing from the initial offset (ie., same state as after calling the constructor).
[Expand]
Inherited Methods
From class com.sun.jndi.ldap.Ber
From class java.lang.Object

Public Constructors

public BerDecoder (byte[] buf, int offset, int bufsize)

Creates a BER decoder that reads bytes from the specified buffer.

Public Methods

public int bytesLeft ()

Returns the number of unparsed bytes in this BER buffer.

public int getParsePosition ()

Returns the current parse position. It points to the byte that will be parsed next. Useful for parsing sequences.

public boolean parseBoolean ()

Parses an ASN_BOOLEAN tagged integer from this BER buffer.

Returns
  • true if the tagged integer is 0; false otherwise.
Throws
Ber.DecodeException

public int parseByte ()

Parses the next byte in this BER buffer.

Returns
  • The byte parsed.
Throws
Ber.DecodeException

public int parseEnumeration ()

Parses an ASN_ENUMERATED tagged integer from this BER buffer.

Returns
  • The tag of enumeration.
Throws
Ber.DecodeException

public int parseInt ()

Parses an ASN_INTEGER tagged integer from this BER buffer.

Returns
  • The value of the integer.
Throws
Ber.DecodeException

public int parseLength ()

Parses a possibly variable length field.

Throws
Ber.DecodeException

public byte[] parseOctetString (int tag, int[] rlen)

Parses an octet string of a given type(tag) from this BER buffer.

 BER Binary Data of type "tag" ::= tag length {byte}*

Parameters
tag The tag to look for.
rlen An array for returning the relative parsed position. If null, the relative parsed position is not returned.
Returns
  • A non-null array containing the octet string.
Throws
If the next byte in the BER buffer is not tag, or if length specified in the BER buffer exceeds the number of bytes left in the buffer.
Ber.DecodeException

public int parseSeq (int[] rlen)

Parses the next sequence in this BER buffer.

Parameters
rlen An array for returning size of the sequence in bytes. If null, the size is not returned.
Returns
  • The sequence's tag.
Throws
Ber.DecodeException

public String parseString (boolean decodeUTF8)

Parses a string.

Throws
Ber.DecodeException

public String parseStringWithTag (int tag, boolean decodeUTF8, int[] rlen)

Parses a string of a given tag from this BER buffer.

BER simple string ::= tag length {byte}*

Parameters
tag The tag that precedes the string.
decodeUTF8 If true, use UTF-8 when decoding the string; otherwise use ISO-Latin-1 (8859_1). Use true for LDAPv3; false for LDAPv2.
rlen An array for holding the relative parsed offset; if null offset not set.
Returns
  • The non-null parsed string.
Throws
Ber.DecodeException

public int peekByte ()

Returns the next byte in this BER buffer without consuming it.

Returns
  • The next byte.
Throws
Ber.DecodeException

public void reset ()

Resets this decode to start parsing from the initial offset (ie., same state as after calling the constructor).