org.apache.directory.shared.ldap.codec.util
Class DNUtils

java.lang.Object
  extended byorg.apache.directory.shared.ldap.codec.util.DNUtils

public class DNUtils
extends java.lang.Object

Utility class used by the LdapDN Parser.

Author:
Apache Directory Project

Field Summary
static int BAD_HEX_PAIR
          If an hex pair contains only one char, this value is returned
static char[] OID_LOWER
          "oid." static
static byte[] OID_LOWER_BYTES
          "oid." static
static char[] OID_UPPER
          "OID." static
static byte[] OID_UPPER_BYTES
          "OID." static
static int ONE_BYTE
          A constant representing one byte length
static int ONE_CHAR
          A constant representing one char length
static int PARSING_ERROR
          A value if we got an error while parsing
static int TWO_BYTES
          A constant representing two bytes length
static int TWO_CHARS
          A constant representing two chars length
 
Constructor Summary
DNUtils()
           
 
Method Summary
static boolean isPairChar(byte[] byteArray, int index)
          Check if the current character is a Pair Char ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]
static boolean isPairChar(char[] charArray, int index)
          Check if the current character is a Pair Char ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]
static int isQuoteChar(byte[] byteArray, int index)
          Check if the current character is a Quote Char We are testing Unicode chars ::= [0x00-0xFFFF] - [\"]
static int isQuoteChar(char[] charArray, int index)
          Check if the current character is a Quote Char We are testing Unicode chars ::= [0x00-0xFFFF] - [\"]
static int isStringChar(byte[] byteArray, int index)
          Check if the current character is a String Char.
static int isStringChar(char[] charArray, int index)
          Check if the current character is a String Char.
static int parseAlphaASCII(byte[] byteArray, int index)
          Walk the buffer while characters are Alpha characters : ::= [0x41-0x5A] | [0x61-0x7A]
static int parseAlphaASCII(char[] charArray, int index)
          Walk the buffer while characters are Alpha characters : ::= [0x41-0x5A] | [0x61-0x7A]
static int parseBase64String(byte[] byteArray, int index)
          Walk the buffer while characters are Base64 characters : ::= ::= | ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A]
static int parseHexPair(byte[] byteArray, int index)
          Parse an hex pair ::=
static int parseHexPair(char[] charArray, int index)
          Parse an hex pair ::=
static int parseHexString(byte[] byteArray, int index)
          Parse an hex string, which is a list of hex pairs ::= ::= | e
static int parseHexString(char[] charArray, int index)
          Parse an hex string, which is a list of hex pairs ::= ::= | e
static int parseSafeString(byte[] byteArray, int index)
          Walk the buffer while characters are Safe String characters : ::= ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F] ::= | ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OID_LOWER

public static final char[] OID_LOWER
"oid." static


OID_UPPER

public static final char[] OID_UPPER
"OID." static


OID_LOWER_BYTES

public static final byte[] OID_LOWER_BYTES
"oid." static


OID_UPPER_BYTES

public static final byte[] OID_UPPER_BYTES
"OID." static


PARSING_ERROR

public static final int PARSING_ERROR
A value if we got an error while parsing

See Also:
Constant Field Values

BAD_HEX_PAIR

public static final int BAD_HEX_PAIR
If an hex pair contains only one char, this value is returned

See Also:
Constant Field Values

ONE_CHAR

public static final int ONE_CHAR
A constant representing one char length

See Also:
Constant Field Values

TWO_CHARS

public static final int TWO_CHARS
A constant representing two chars length

See Also:
Constant Field Values

ONE_BYTE

public static final int ONE_BYTE
A constant representing one byte length

See Also:
Constant Field Values

TWO_BYTES

public static final int TWO_BYTES
A constant representing two bytes length

See Also:
Constant Field Values
Constructor Detail

DNUtils

public DNUtils()
Method Detail

parseSafeString

public static int parseSafeString(byte[] byteArray,
                                  int index)
Walk the buffer while characters are Safe String characters : ::= ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F] ::= | ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F]

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The position of the first character which is not a Safe Char

parseAlphaASCII

public static int parseAlphaASCII(byte[] byteArray,
                                  int index)
Walk the buffer while characters are Alpha characters : ::= [0x41-0x5A] | [0x61-0x7A]

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The position of the first character which is not an Alpha Char

parseAlphaASCII

public static int parseAlphaASCII(char[] charArray,
                                  int index)
Walk the buffer while characters are Alpha characters : ::= [0x41-0x5A] | [0x61-0x7A]

Parameters:
charArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The position of the first character which is not an Alpha Char

isPairChar

public static boolean isPairChar(byte[] byteArray,
                                 int index)
Check if the current character is a Pair Char ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
true if the current character is a Pair Char

isPairChar

public static boolean isPairChar(char[] charArray,
                                 int index)
Check if the current character is a Pair Char ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]

Parameters:
charArray - The buffer which contains the data
index - Current position in the buffer
Returns:
true if the current character is a Pair Char

isStringChar

public static int isStringChar(byte[] byteArray,
                               int index)
Check if the current character is a String Char. Chars are Unicode, not ASCII. ::= [0x00-0xFFFF] - [,=+<>#;\"\n\r]

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The current char if it is a String Char, or '#' (this is simpler than throwing an exception :)

isStringChar

public static int isStringChar(char[] charArray,
                               int index)
Check if the current character is a String Char. Chars are Unicode, not ASCII. ::= [0x00-0xFFFF] - [,=+<>#;\"\n\r]

Parameters:
charArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The current char if it is a String Char, or '#' (this is simpler than throwing an exception :)

isQuoteChar

public static int isQuoteChar(byte[] byteArray,
                              int index)
Check if the current character is a Quote Char We are testing Unicode chars ::= [0x00-0xFFFF] - [\"]

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
true if the current character is a Quote Char

isQuoteChar

public static int isQuoteChar(char[] charArray,
                              int index)
Check if the current character is a Quote Char We are testing Unicode chars ::= [0x00-0xFFFF] - [\"]

Parameters:
charArray - The buffer which contains the data
index - Current position in the buffer
Returns:
true if the current character is a Quote Char

parseHexPair

public static int parseHexPair(byte[] byteArray,
                               int index)
Parse an hex pair ::=

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The new position, -1 if the buffer does not contain an HexPair, -2 if the buffer contains an hex byte but not two.

parseHexPair

public static int parseHexPair(char[] charArray,
                               int index)
Parse an hex pair ::=

Parameters:
charArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The new position, -1 if the buffer does not contain an HexPair, -2 if the buffer contains an hex byte but not two.

parseHexString

public static int parseHexString(byte[] byteArray,
                                 int index)
Parse an hex string, which is a list of hex pairs ::= ::= | e

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
Return the first position which is not an hex pair, or -1 if there is no hexpair at the beginning or if an hexpair is invalid (if we have only one hex instead of 2)

parseHexString

public static int parseHexString(char[] charArray,
                                 int index)
Parse an hex string, which is a list of hex pairs ::= ::= | e

Parameters:
charArray - The buffer which contains the data
index - Current position in the buffer
Returns:
Return the first position which is not an hex pair, or -1 if there is no hexpair at the beginning or if an hexpair is invalid (if we have only one hex instead of 2)

parseBase64String

public static int parseBase64String(byte[] byteArray,
                                    int index)
Walk the buffer while characters are Base64 characters : ::= ::= | ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A]

Parameters:
byteArray - The buffer which contains the data
index - Current position in the buffer
Returns:
The position of the first character which is not a Base64 Char


Copyright © 2003-2006 . All Rights Reserved.