|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.directory.shared.ldap.name.RDN
public class RDN
This class store 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
or
ou=value + ou=another 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.
The Rdn is composed of one or more AttributeTypeAndValue (atav) Those atavs
are ordered in the alphabetical natural order : a < b < c ... < z As the type
are not case sensitive, we can say that a = A
Field Summary | |
---|---|
protected AVA |
atav
A simple AttributeTypeAndValue is used to store the Rdn for the simple case where we only have a single type=value. |
static RDN |
EMPTY_RDN
An empty RDN |
static int |
EQUAL
Constant used in comparisons |
static int |
INFERIOR
Constant used in comparisons |
protected static org.slf4j.Logger |
LOG
The LoggerFactory used by this class |
static int |
SUPERIOR
Constant used in comparisons |
static int |
UNDEFINED
CompareTo() results |
Constructor Summary | |
---|---|
RDN()
A empty constructor. |
|
RDN(RDN rdn)
Constructs an Rdn from the given rdn. |
|
RDN(java.lang.String rdn)
A constructor that parse a String representing a RDN. |
|
RDN(java.lang.String upType,
java.lang.String upValue)
A constructor that constructs a RDN from a type and a value. |
|
RDN(java.lang.String upType,
java.lang.String normType,
java.lang.String upValue,
java.lang.String normValue)
A constructor that constructs a RDN from a type and a value. |
Method Summary | |
---|---|
void |
clear()
Clear the RDN, removing all the AttributeTypeAndValues. |
java.lang.Object |
clone()
Clone the Rdn |
int |
compareTo(RDN rdn)
Compares two RDNs. |
boolean |
equals(java.lang.Object rdn)
Compares the specified Object with this Rdn for equality. |
static java.lang.String |
escapeValue(byte[] attrValue)
Transform a value in a String, accordingly to RFC 2253 |
static java.lang.String |
escapeValue(java.lang.String value)
Transform a value in a String, accordingly to RFC 2253 |
AVA |
getAtav()
Return the unique AttributeTypeAndValue, or the first one of we have more than one |
AVA |
getAttributeTypeAndValue(java.lang.String type)
Get the AttributeTypeAndValue which type is given as an argument. |
int |
getLength()
Get the Rdn length |
java.lang.String |
getName()
|
int |
getNbAtavs()
|
java.lang.String |
getNormName()
|
java.lang.String |
getNormType()
Return the normalized type, or the first one of we have more than one (the lowest) |
java.lang.String |
getNormValue()
Return the normalized value, or the first one of we have more than one (the lowest) |
int |
getStart()
Get the start position |
java.lang.String |
getUpType()
Return the user provided type, or the first one of we have more than one (the lowest) |
java.lang.String |
getUpValue()
Return the User Provided value |
java.lang.Object |
getValue(java.lang.String type)
Get the Value of the AttributeTypeAndValue which type is given as an argument. |
int |
hashCode()
Gets the hashcode of this rdn. |
java.util.Iterator<AVA> |
iterator()
Retrieves the components of this RDN as an iterator of AttributeTypeAndValue. |
RDN |
normalize(java.util.Map<java.lang.String,OidNormalizer> oidsMap)
Transform a RDN by changing the value to its OID counterpart and normalizing the value accordingly to its type. |
void |
readExternal(java.io.ObjectInput in)
|
void |
setUpName(java.lang.String upName)
Set the User Provided Name |
int |
size()
Get the number of Attribute type and value of this Rdn |
java.lang.String |
toString()
|
static java.lang.Object |
unescapeValue(java.lang.String value)
Unescape the given string according to RFC 2253 If in |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final org.slf4j.Logger LOG
public static final RDN EMPTY_RDN
protected AVA atav
public static final int UNDEFINED
public static final int SUPERIOR
public static final int INFERIOR
public static final int EQUAL
Constructor Detail |
---|
public RDN()
public RDN(java.lang.String rdn) throws LdapInvalidDnException
rdn
- The String containing the RDN to parse
LdapInvalidDnException
- If the RDN is invalidpublic RDN(java.lang.String upType, java.lang.String normType, java.lang.String upValue, java.lang.String normValue) throws LdapInvalidDnException
upType
- The user provided type of the RDNupValue
- The user provided value of the RDNnormType
- The normalized provided type of the RDNnormValue
- The normalized provided value of the RDN
LdapInvalidDnException
- If the RDN is invalidpublic RDN(java.lang.String upType, java.lang.String upValue) throws LdapInvalidDnException
upType
- The user provided type of the RDNupValue
- The user provided value of the RDN
LdapInvalidDnException
- If the RDN is invalidpublic RDN(RDN rdn)
rdn
- The non-null Rdn to be copied.Method Detail |
---|
public RDN normalize(java.util.Map<java.lang.String,OidNormalizer> oidsMap) throws LdapInvalidDnException
rdn
- The RDN to modify.oidsMap
- The map of all existing oids and normalizer.
LdapException
- If the RDN is invalid.
LdapInvalidDnException
public void clear()
public java.lang.Object getValue(java.lang.String type) throws LdapInvalidDnException
type
- The type of the NameArgument
LdapInvalidDnException
public int getStart()
public int getLength()
public AVA getAttributeTypeAndValue(java.lang.String type)
type
- The type of the NameArgument to be returned
public java.util.Iterator<AVA> iterator()
iterator
in interface java.lang.Iterable<AVA>
public java.lang.Object clone()
clone
in class java.lang.Object
public int compareTo(RDN rdn)
compareTo
in interface java.lang.Comparable<RDN>
object
-
public java.lang.String getName()
public java.lang.String getNormName()
public void setUpName(java.lang.String upName)
upName
- the User Provided damepublic int getNbAtavs()
public AVA getAtav()
public java.lang.String getUpType()
public java.lang.String getNormType()
public java.lang.String getUpValue()
public java.lang.String getNormValue()
public boolean equals(java.lang.Object rdn)
equals
in class java.lang.Object
rdn
- Rdn to be compared for equality with this Rdn
public int size()
public static java.lang.Object unescapeValue(java.lang.String value)
value
- The value to be unescaped
java.lang.IllegalArgumentException
- -
When an Illegal value is provided.public static java.lang.String escapeValue(java.lang.String value)
value
- The attribute value to be escaped
public static java.lang.String escapeValue(byte[] attrValue)
attrValue
- The attribute value to be escaped
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The stream into which the serialized RDN will be put
java.io.IOException
- If the stream can't be writtenA RDN is composed of on to many ATAVs (AttributeType And Value).
We should write all those ATAVs sequencially, following the
structure :
- nbAtavs
The number of ATAVs to write. Can't be 0.
- upName
The User provided RDN
- normName
The normalized RDN. It can be empty if the normalized
name equals the upName.
- atavs
For each ATAV :
- start
The position of this ATAV in the upName string
- length
The ATAV user provided length
- Call the ATAV write method
The ATAV itself
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- The input stream from which the RDN will be read
java.io.IOException
- If we can't read from the input stream
java.lang.ClassNotFoundException
- If we can't create a new RDNWe read back the data to create a new RDB. The structure
read is exposed in the {@link RDN#writeExternal(ObjectOutput)}
method
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |