org.apache.directory.shared.ldap.name
Class RdnParser

java.lang.Object
  extended by org.apache.directory.shared.ldap.name.RdnParser

public class RdnParser
extends java.lang.Object

This class parse the name-component part or the following BNF grammar (as of RFC2253, par. 3, and RFC1779, fig. 1) :
- <name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <attributeTypeAndValues>
- <attributeTypeAndValues> ::= <spaces> '+' <spaces> <attributeType> <spaces> '=' <spaces> <attributeValue> <attributeTypeAndValues> | e
- <attributeType> ::= [a-zA-Z] <keychars> | <oidPrefix> [0-9] <digits> <oids> | [0-9] <digits> <oids>
- <keychars> ::= [a-zA-Z] <keychars> | [0-9] <keychars> | '-' <keychars> | e
- <oidPrefix> ::= 'OID.' | 'oid.' | e
- <oids> ::= '.' [0-9] <digits> <oids> | e
- <attributeValue> ::= <pairs-or-strings> | '#' <hexstring> |'"' <quotechar-or-pairs> '"'
- <pairs-or-strings> ::= '\' <pairchar> <pairs-or-strings> | <stringchar> <pairs-or-strings> | e
- <quotechar-or-pairs> ::= <quotechar> <quotechar-or-pairs> | '\' <pairchar> <quotechar-or-pairs> | e
- <pairchar> ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]
- <hexstring> ::= [0-9a-fA-F] [0-9a-fA-F] <hexpairs>
- <hexpairs> ::= [0-9a-fA-F] [0-9a-fA-F] <hexpairs> | e
- <digits> ::= [0-9] <digits> | e
- <stringchar> ::= [0x00-0xFF] - [,=+<>#;\"\n\r]
- <quotechar> ::= [0x00-0xFF] - [\"]
- <separator> ::= ',' | ';'
- <spaces> ::= ' ' <spaces> | e

A RDN is a part of a DN. It can be composed of many types, as in the RDN following RDN :
ou=value + cn=other value

In this case, we have to store an 'ou' and a 'cn' in the RDN.

The types are case insensitive.
Spaces before and after types and values are not stored.
Spaces before and after '+' are not stored.

Thus, we can consider that the following RDNs are equals :

'ou=test 1'
' ou=test 1'
'ou =test 1'
'ou= test 1'
'ou=test 1 '
' ou = test 1 '

So are the following :

'ou=test 1+cn=test 2'
'ou = test 1 + cn = test 2'
' ou =test 1+ cn =test 2 '
'cn = test 2 +ou = test 1'

but the following are not equal :
'ou=test 1'
'ou=test 1'
because we have more than one spaces inside the value.

Version:
$Rev: 675000 $, $Date: 2008-07-09 00:12:03 +0200 (Mi, 09 Jul 2008) $
Author:
Apache Directory Project

Constructor Summary
RdnParser()
           
 
Method Summary
static boolean isValid(byte[] dn, Position pos, boolean isFirstRdn)
          Validate a NameComponent :
static boolean isValid(java.lang.String dn)
          Validtae a NameComponent :
static int parse(byte[] dn, Position pos, Rdn rdn)
          Parse a NameComponent :
static int parse(java.lang.String dn, Position pos, Rdn rdn)
          Parse a NameComponent :
static void parse(java.lang.String dn, Rdn rdn)
          Parse a NameComponent :
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RdnParser

public RdnParser()
Method Detail

parse

public static int parse(java.lang.String dn,
                        Position pos,
                        Rdn rdn)
                 throws javax.naming.InvalidNameException
Parse a NameComponent :

<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>

Parameters:
dn - The String to parse
pos - The current position in the buffer
rdn - The constructed RDN
Returns:
The new position in the char array, or PARSING_ERROR if the rule does not apply to the char array
Throws:
javax.naming.InvalidNameException - If the NameComponent is invalid

parse

public static int parse(byte[] dn,
                        Position pos,
                        Rdn rdn)
                 throws javax.naming.InvalidNameException
Parse a NameComponent :

<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>

Parameters:
dn - The byte array to parse
pos - The current position in the buffer
rdn - The constructed RDN
Returns:
The new position in the byte array, or PARSING_ERROR if the rule does not apply to the byte array
Throws:
javax.naming.InvalidNameException - If the NameComponent is invalid

isValid

public static boolean isValid(byte[] dn,
                              Position pos,
                              boolean isFirstRdn)
Validate a NameComponent :

<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>

Parameters:
dn - The byte array to parse
pos - The current position in the buffer
isFirstRdn - a flag set if the RDN is the first for the current DN
Returns:
true if the RDN is valid

parse

public static void parse(java.lang.String dn,
                         Rdn rdn)
                  throws javax.naming.InvalidNameException
Parse a NameComponent :

<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>

Parameters:
dn - The String to parse
rdn - The RDN to fill. Beware that if the RDN is not empty, the new AttributeTypeAndValue will be added.
Throws:
javax.naming.InvalidNameException - If the NameComponent is invalid

isValid

public static boolean isValid(java.lang.String dn)
Validtae a NameComponent :

<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>

Parameters:
dn - The string to parse
Returns:
true if the RDN is valid


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.