public class Rdn extends Object implements Cloneable, Externalizable, Iterable<Ava>, 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 List<Ava> |
avas
Stores all couple type = value.
|
private String |
avaType
We keep the type for a single valued Rdn, to avoid the creation of an HashMap
|
private Map<String,List<Ava>> |
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 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 String |
upName
The User Provided Rdn
|
| Constructor and Description |
|---|
Rdn()
A empty constructor.
|
Rdn(Ava... avas)
Creates a new RDN from a list of AVA
|
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)
Creates a new schema aware RDN from a list of AVA
|
Rdn(SchemaManager schemaManager,
Rdn rdn)
Constructs an Rdn from the given rdn.
|
Rdn(SchemaManager schemaManager,
String rdn)
A constructor that parse a String representing a schema aware Rdn.
|
Rdn(SchemaManager schemaManager,
String upType,
String upValue)
A constructor that constructs a schema aware Rdn from a type and a value.
|
Rdn(String rdn)
A constructor that parse a String representing a Rdn.
|
Rdn(String upType,
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 addedAva)
Add an Ava to the current schema aware Rdn
|
private void |
addAVA(SchemaManager schemaManager,
String type,
Value value)
Add an Ava to the current Rdn
|
private List<Ava> |
addOrdered(List<Ava> avaList,
Ava newAva)
Add an AVA in a List of Ava, at the right place (ordered)
|
private void |
buildNormRdn(StringBuilder sb,
Ava ava) |
(package private) void |
clear()
Clear the Rdn, removing all the Avas.
|
Rdn |
clone()
Clone the Rdn
|
int |
compareTo(Rdn otherRdn)
Compare the current RDN with the provided one.
|
int |
deserialize(byte[] buffer,
int pos)
Deserialize a RDN from a byte[], starting at a given position
|
boolean |
equals(Object that)
Compares the specified Object with this Rdn for equality.
|
static String |
escapeValue(byte[] attrValue)
Transform a value in a String, accordingly to RFC 2253
|
static String |
escapeValue(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(int pos)
Return the Nth Ava
|
Ava |
getAva(String type)
Get the Ava which type is given as an argument.
|
String |
getEscaped() |
String |
getName() |
String |
getNormName() |
String |
getNormType()
Return the normalized type, or the first one of we have more than one (the lowest)
|
String |
getType()
Return the user provided type, or the first one of we have more than one (the lowest)
|
String |
getValue()
Return the User Provided value, as a String
|
Object |
getValue(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(SchemaManager schemaManager,
String dn)
Validate a NameComponent :
|
static boolean |
isValid(String dn)
Validate a NameComponent :
|
Iterator<Ava> |
iterator()
Retrieves the components of this Rdn as an iterator of Avas.
|
private static void |
parse(SchemaManager schemaManager,
String dn,
Rdn rdn)
Parse a NameComponent :
|
void |
readExternal(ObjectInput in)
We read back the data to create a new RDB.
|
int |
serialize(byte[] buffer,
int pos)
Serialize a RDN into a byte[]
|
(package private) void |
setNormName(String normName)
Set the normalized Name.
|
(package private) void |
setUpName(String upName)
Set the User Provided Name.
|
int |
size()
Get the number of Avas of this Rdn
|
String |
toString() |
static Object |
unescapeValue(String value)
Unescape the given string according to RFC 2253 If in <string> form, a
LDAP string representation asserted value can be obtained by replacing
(left-to-right, non-recursively) each <pair> appearing in the <string> as
follows:
replace <ESC><ESC> with <ESC>
replace <ESC><special> with <special>
replace <ESC><hexpair> with the octet indicated by the <hexpair>
If in <hexstring> form, a BER representation can be obtained
from converting each <hexpair> of the <hexstring> to the octet indicated
by the <hexpair>
|
void |
writeExternal(ObjectOutput out)
A Rdn is composed of on to many Avas (AttributeType And Value).
|
finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected static final org.slf4j.Logger LOG
public static final Rdn EMPTY_RDN
private static final long serialVersionUID
private String upName
private String normName
private transient List<Ava> avas
private transient Map<String,List<Ava>> avaTypes
private 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 transient SchemaManager schemaManager
private volatile int h
public Rdn()
public Rdn(SchemaManager schemaManager)
schemaManager - the schema managerpublic Rdn(SchemaManager schemaManager, String rdn) throws LdapInvalidDnException
schemaManager - the schema managerrdn - the String containing the Rdn to parseLdapInvalidDnException - if the Rdn is invalidpublic Rdn(String rdn) throws LdapInvalidDnException
rdn - the String containing the Rdn to parseLdapInvalidDnException - if the Rdn is invalidpublic Rdn(SchemaManager schemaManager, String upType, String upValue) throws LdapInvalidDnException, LdapInvalidAttributeValueException
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 invalidLdapInvalidAttributeValueException - If the given AttributeType or value are invalidpublic Rdn(String upType, String upValue) throws LdapInvalidDnException, LdapInvalidAttributeValueException
upType - the user provided type of the RdnupValue - the user provided value of the RdnLdapInvalidDnException - if the Rdn is invalidLdapInvalidAttributeValueException - If the given AttributeType or Value are incorrectRdn( SchemaManager, String, String )public Rdn(SchemaManager schemaManager, Ava... avas) throws LdapInvalidDnException
schemaManager - The schemaManager to useavas - The AVA that will be usedLdapInvalidDnException - If the RDN is invalidpublic Rdn(Ava... avas) throws LdapInvalidDnException
avas - The AVA that will be usedLdapInvalidDnException - If the RDN is invalidpublic Rdn(Rdn rdn)
rdn - The non-null Rdn to be copied.public Rdn(SchemaManager schemaManager, Rdn rdn) throws LdapInvalidDnException
schemaManager - The SchemaManagerrdn - The non-null Rdn to be copied.LdapInvalidDnException - If the given Rdn is invalidprivate List<Ava> addOrdered(List<Ava> avaList, Ava newAva)
avaList - The list of AvanewAva - The Ava to addprivate void addAVA(SchemaManager schemaManager, String type, Value value) throws LdapInvalidDnException
schemaManager - The SchemaManagertype - The user provided type of the added Rdn.value - The user provided provided value of the added RdnLdapInvalidDnException - If the Rdn is invalidvoid addAVA(SchemaManager schemaManager, Ava addedAva) throws LdapInvalidDnException
schemaManager - The SchemaManageraddedAva - The added AvaLdapInvalidDnException - If the Ava is invalidvoid clear()
public Object getValue(String type) throws LdapInvalidDnException
type - the type of the NameArgumentLdapInvalidDnException - if the Rdn is invalidpublic Ava getAva(String type)
type - The type of the NameArgument to be returnedpublic Iterator<Ava> iterator()
public Rdn clone()
public String getName()
void setUpName(String upName)
upName - the User Provided damepublic String getNormName()
void setNormName(String normName)
normName - the Normalized damepublic Ava getAva()
public Ava getAva(int pos)
pos - The Ava we are looking forpublic String getType()
public String getNormType()
public String getValue()
public boolean equals(Object that)
public int size()
public static Object unescapeValue(String value)
value - The value to be unescapedIllegalArgumentException - When an Illegal value is provided.public static String escapeValue(String value)
value - The attribute value to be escapedpublic String getEscaped()
public static String escapeValue(byte[] attrValue)
attrValue - The attribute value to be escapedpublic boolean isSchemaAware()
true if the Rdn is schema awarepublic static boolean isValid(String dn)
<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>
dn - The string to parsetrue if the Rdn is validpublic static boolean isValid(SchemaManager schemaManager, String dn)
<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>
schemaManager - The Schemamanager to usedn - The string to parsetrue if the Rdn is validprivate static void parse(SchemaManager schemaManager, String dn, Rdn rdn) throws LdapInvalidDnException
<name-component> ::= <attributeType> <spaces> '=' <spaces> <attributeValue> <nameComponents>
schemaManager - The SchemaManagerdn - 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 ObjectObject.hashCode()public int serialize(byte[] buffer,
int pos)
throws IOException
buffer - The buffer which will contain the serilaized form of this RDNpos - The position in the buffer where to store the RDNIOException - If the serialization failedpublic int deserialize(byte[] buffer,
int pos)
throws IOException,
LdapInvalidAttributeValueException
buffer - The buffer containing the RDNpos - The position in the bufferIOException - If the serialized value is not a RDNLdapInvalidAttributeValueException - If the serialized RDN is invalidpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface Externalizableout - The stream into which the serialized Rdn will be putIOException - If the stream can't be writtenExternalizable.readExternal(ObjectInput)public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
writeExternal(ObjectOutput)
methodreadExternal in interface Externalizablein - The input stream from which the Rdn will be readIOException - If we can't read from the input streamClassNotFoundException - If we can't create a new RdnExternalizable.readExternal(ObjectInput)private void buildNormRdn(StringBuilder sb, Ava ava)
public int compareTo(Rdn otherRdn)
compareTo in interface Comparable<Rdn>otherRdn - The RDN we want to compare toCopyright © 2003–2019 The Apache Software Foundation. All rights reserved.