public class Rdn extends java.lang.Object implements java.lang.Cloneable, java.io.Externalizable, java.lang.Iterable<Ava>, java.lang.Comparable<Rdn>
| Modifier and Type | Field and Description |
|---|---|
protected Ava |
ava
A simple Ava is used to store the Rdn for the simple
case where we only have a single type=value.
|
private java.util.List<Ava> |
avas
Stores all couple type = value.
|
private java.lang.String |
avaType
We keep the type for a single valued Rdn, to avoid the creation of an HashMap
|
private org.apache.commons.collections.MultiMap |
avaTypes
We also keep a set of types, in order to use manipulations.
|
static Rdn |
EMPTY_RDN
An empty Rdn
|
static int |
EQUAL
Constant used in comparisons
|
private int |
h
The computed hashcode
|
static int |
INFERIOR
Constant used in comparisons
|
protected static org.slf4j.Logger |
LOG
The LoggerFactory used by this class
|
private int |
nbAvas
The number of Avas.
|
private boolean |
normalized
A flag used to tell if the Rdn has been normalized
|
private java.lang.String |
normName
The normalized Rdn
|
private SchemaManager |
schemaManager
the schema manager
|
private static long |
serialVersionUID
Declares the Serial Version Uid.
|
static int |
SUPERIOR
Constant used in comparisons
|
static int |
UNDEFINED
CompareTo() results
|
private java.lang.String |
upName
The User Provided Rdn
|
| Constructor and Description |
|---|
Rdn()
A empty constructor.
|
Rdn(Ava... avas) |
Rdn(Rdn rdn)
Constructs an Rdn from the given rdn.
|
Rdn(SchemaManager schemaManager)
Creates a new schema aware instance of Rdn.
|
Rdn(SchemaManager schemaManager,
Ava... avas) |
Rdn(SchemaManager schemaManager,
java.lang.String rdn)
A constructor that parse a String representing a schema aware Rdn.
|
Rdn(SchemaManager schemaManager,
java.lang.String upType,
java.lang.String upValue)
A constructor that constructs a schema aware Rdn from a type and a value.
|
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.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addAVA(SchemaManager schemaManager,
Ava value)
Add an Ava to the current schema aware Rdn
|
private void |
addAVA(SchemaManager schemaManager,
java.lang.String upType,
java.lang.String type,
Value<?> value)
Add an Ava to the current Rdn
|
Rdn |
apply(SchemaManager schemaManager)
Transform a Rdn by changing the value to its OID counterpart and
normalizing the value accordingly to its type.
|
(package private) void |
clear()
Clear the Rdn, removing all the Avas.
|
Rdn |
clone()
Clone the Rdn
|
int |
compareTo(Rdn arg0) |
int |
deserialize(byte[] buffer,
int pos)
Deserialize a RDN from a byte[], starting at a given position
|
boolean |
equals(java.lang.Object that)
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 |
getAva()
Return the unique Ava, or the first one of we have more
than one
|
Ava |
getAva(java.lang.String type)
Get the Ava which type is given as an argument.
|
java.lang.String |
getName() |
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, as a String
|
java.lang.Object |
getNormValue(java.lang.String type)
Get the normalized value of the Ava which type is given as an
argument.
|
java.lang.String |
getType()
Return the user provided type, or the first one of we have more than one (the lowest)
|
java.lang.String |
getValue()
Return the User Provided value, as a String
|
java.lang.Object |
getValue(java.lang.String type)
Get the value of the Ava which type is given as an
argument.
|
int |
hashCode()
Gets the hashcode of this rdn.
|
boolean |
isSchemaAware()
Tells if the Rdn is schema aware.
|
static boolean |
isValid(java.lang.String dn)
Validate a NameComponent :
|
java.util.Iterator<Ava> |
iterator()
Retrieves the components of this Rdn as an iterator of Avas.
|
(package private) void |
normalize()
Transform the external representation of the current Rdn to an internal
normalized form where :
- types are trimmed and lower cased
- values are trimmed and lower cased
|
private static void |
parse(java.lang.String dn,
Rdn rdn)
Parse a NameComponent :
|
void |
readExternal(java.io.ObjectInput in)
We read back the data to create a new RDB.
|
(package private) void |
replaceAva(Ava value,
int pos)
Replace an Ava into a Rdn at a given position
|
int |
serialize(byte[] buffer,
int pos)
Serialize a RDN into a byte[]
|
(package private) void |
setUpName(java.lang.String upName)
Set the User Provided Name.
|
int |
size()
Get the number of Avas 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)
A Rdn is composed of on to many Avas (AttributeType And Value).
|
protected static final org.slf4j.Logger LOG
public static final Rdn EMPTY_RDN
private static final long serialVersionUID
private java.lang.String upName
private java.lang.String normName
private java.util.List<Ava> avas
private org.apache.commons.collections.MultiMap avaTypes
private java.lang.String avaType
protected Ava ava
private int nbAvas
public static final int UNDEFINED
public static final int SUPERIOR
public static final int INFERIOR
public static final int EQUAL
private boolean normalized
private SchemaManager schemaManager
private volatile int h
public Rdn()
public Rdn(SchemaManager schemaManager)
schemaManager - the schema managerpublic Rdn(SchemaManager schemaManager, java.lang.String rdn) throws LdapInvalidDnException
schemaManager - the schema managerrdn - the String containing the Rdn to parseLdapInvalidDnException - if the Rdn is invalidpublic Rdn(java.lang.String rdn)
throws LdapInvalidDnException
rdn - the String containing the Rdn to parseLdapInvalidDnException - if the Rdn is invalidpublic Rdn(SchemaManager schemaManager, java.lang.String upType, java.lang.String upValue) throws LdapInvalidDnException
The string attribute values are not interpreted as RFC 414 formatted Rdn strings. That is, the values are used literally (not parsed) and assumed to be un-escaped.
schemaManager - the schema managerupType - the user provided type of the RdnupValue - the user provided value of the RdnLdapInvalidDnException - 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 RdnLdapInvalidDnException - if the Rdn is invalidRdn( SchemaManager, String, String )public Rdn(SchemaManager schemaManager, Ava... avas) throws LdapInvalidDnException
LdapInvalidDnExceptionpublic Rdn(Ava... avas) throws LdapInvalidDnException
LdapInvalidDnExceptionpublic Rdn(Rdn rdn)
rdn - The non-null Rdn to be copied.void normalize()
public Rdn apply(SchemaManager schemaManager) throws LdapInvalidDnException
schemaManager - the SchemaManagerLdapInvalidDnException - if the Rdn is invalidprivate void addAVA(SchemaManager schemaManager, java.lang.String upType, java.lang.String type, Value<?> value) throws LdapInvalidDnException
upType - The user provided type of the added Rdn.type - The normalized provided type of the added Rdn.upValue - The user provided value of the added Rdnvalue - The normalized provided value of the added RdnLdapInvalidDnException - If the Rdn is invalidvoid replaceAva(Ava value, int pos) throws LdapInvalidDnException
value - The modified Avapos - The position of the Ava in the RdnLdapInvalidDnException - If the position is not validvoid addAVA(SchemaManager schemaManager, Ava value) throws LdapInvalidDnException
value - The added AvaLdapInvalidDnExceptionvoid clear()
public java.lang.Object getValue(java.lang.String type)
throws LdapInvalidDnException
type - the type of the NameArgumentLdapInvalidDnException - if the Rdn is invalidpublic java.lang.Object getNormValue(java.lang.String type)
throws LdapInvalidDnException
type - the type of the NameArgumentLdapInvalidDnException - if the Rdn is invalidpublic Ava getAva(java.lang.String type)
type - The type of the NameArgument to be returnedpublic java.util.Iterator<Ava> iterator()
iterator in interface java.lang.Iterable<Ava>public Rdn clone()
clone in class java.lang.Objectpublic java.lang.String getName()
public java.lang.String getNormName()
void setUpName(java.lang.String upName)
upName - the User Provided damepublic Ava getAva()
public java.lang.String getType()
public java.lang.String getNormType()
public java.lang.String getValue()
public java.lang.String getNormValue()
public boolean equals(java.lang.Object that)
equals in class java.lang.Objectrdn - Rdn to be compared for equality with this Rdnpublic int size()
public static java.lang.Object unescapeValue(java.lang.String value)
throws java.lang.IllegalArgumentException
value - The value to be unescapedjava.lang.IllegalArgumentException - When an Illegal value is provided.public static java.lang.String escapeValue(java.lang.String value)
value - The attribute value to be escapedpublic static java.lang.String escapeValue(byte[] attrValue)
attrValue - The attribute value to be escapedpublic boolean isSchemaAware()
true if the Rdn is schema awarepublic static boolean isValid(java.lang.String dn)
<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>
dn - The string to parsetrue if the Rdn is validprivate static void parse(java.lang.String dn,
Rdn rdn)
throws LdapInvalidDnException
<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>
dn - The String to parserdn - The Rdn to fill. Beware that if the Rdn is not empty, the new
AttributeTypeAndValue will be added.LdapInvalidDnException - If the NameComponent is invalidpublic int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public int serialize(byte[] buffer,
int pos)
throws java.io.IOException
java.io.IOExceptionpublic int deserialize(byte[] buffer,
int pos)
throws java.io.IOException,
LdapInvalidAttributeValueException
buffer - The buffer containing the RDNpos - The position in the bufferjava.io.IOException - If the serialized value is not a RDNLdapInvalidAttributeValueException - If the serialized RDN is invalidpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizableout - The stream into which the serialized Rdn will be putjava.io.IOException - If the stream can't be writtenExternalizable.readExternal(ObjectInput)public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
writeExternal(ObjectOutput)
methodreadExternal in interface java.io.Externalizablein - The input stream from which the Rdn will be readjava.io.IOException - If we can't read from the input streamjava.lang.ClassNotFoundException - If we can't create a new RdnExternalizable.readExternal(ObjectInput)public int compareTo(Rdn arg0)
compareTo in interface java.lang.Comparable<Rdn>public java.lang.String toString()
toString in class java.lang.Object