Package org.ldaptive.dn
Class Dn
- java.lang.Object
-
- org.ldaptive.dn.Dn
-
public class Dn extends java.lang.ObjectDistinguished name containing zero or more relative distinguished names. RDNs are ordered from left to right such that the left-most RDN is considered the first. For the DN 'cn=Jane Doe,ou=People,dc=ldaptive,dc=org', the first RDN is 'cn=Jane Doe'. See RFC 4514 for more details on the string representations of DNs.- Author:
- Middleware Services
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDn.Builder
-
Constructor Summary
Constructors Constructor Description Dn()Default constructor.Dn(java.lang.String dn)Creates a new DN with the supplied string.Dn(java.lang.String dn, DnParser parser)Creates a new DN with the supplied string.Dn(java.util.List<RDn> rdns)Creates a new DN with the supplied RDNs.Dn(RDn... rdn)Creates a new DN with the supplied RDNs.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, RDn rdn)Adds the supplied RDN at the supplied index.voidadd(Dn dn)Adds all the RDNs in the supplied DN to the end of this DN.voidadd(RDn rdn)Adds the supplied RDN to the end of this DN.static Dn.Builderbuilder()Creates a builder for this class.booleanequals(java.lang.Object o)java.lang.Stringformat()Produces a string representation of this DN.java.lang.Stringformat(RDnNormalizer normalizer)Produces a string representation of this DN.RDngetRDn()Returns the first RDN in this DN.java.util.List<RDn>getRDns()Returns the RDNs in this DN.java.lang.StringgetValue(java.lang.String name)Returns the first RDN value with the supplied name.java.util.Collection<java.lang.String>getValues(java.lang.String name)Returns the RDN values with the supplied name.inthashCode()intsize()Returns the number of RDNs in this DN.DnsubDn(int index)Returns a new DN containing all the RDN components from the supplied index.DnsubDn(int beginIndex, int endIndex)Returns a new DN containing all the RDN components between the supplied indexes.java.lang.StringtoString()
-
-
-
Constructor Detail
-
Dn
public Dn()
Default constructor.
-
Dn
public Dn(java.lang.String dn)
Creates a new DN with the supplied string.- Parameters:
dn- to parse
-
Dn
public Dn(java.lang.String dn, DnParser parser)Creates a new DN with the supplied string.- Parameters:
dn- to parseparser- to parse dn
-
Dn
public Dn(RDn... rdn)
Creates a new DN with the supplied RDNs.- Parameters:
rdn- to add
-
Dn
public Dn(java.util.List<RDn> rdns)
Creates a new DN with the supplied RDNs.- Parameters:
rdns- to add
-
-
Method Detail
-
getRDn
public RDn getRDn()
Returns the first RDN in this DN.- Returns:
- first RDN
-
getRDns
public java.util.List<RDn> getRDns()
Returns the RDNs in this DN.- Returns:
- RDNs
-
add
public void add(Dn dn)
Adds all the RDNs in the supplied DN to the end of this DN.- Parameters:
dn- to add to this DN
-
add
public void add(RDn rdn)
Adds the supplied RDN to the end of this DN.- Parameters:
rdn- to add to this DN
-
add
public void add(int index, RDn rdn)Adds the supplied RDN at the supplied index.- Parameters:
index- to add the RDN atrdn- to add to this DN
-
subDn
public Dn subDn(int index)
Returns a new DN containing all the RDN components from the supplied index.- Parameters:
index- of RDNs to include- Returns:
- DN with sub-components of this DN
-
subDn
public Dn subDn(int beginIndex, int endIndex)
Returns a new DN containing all the RDN components between the supplied indexes.- Parameters:
beginIndex- first RDN to include (inclusive)endIndex- last RDN to include (exclusive)- Returns:
- DN with sub-components of this DN
-
getValues
public java.util.Collection<java.lang.String> getValues(java.lang.String name)
Returns the RDN values with the supplied name. If the RDN is multi-value the first value is used.- Parameters:
name- of the RDN- Returns:
- RDN value
-
getValue
public java.lang.String getValue(java.lang.String name)
Returns the first RDN value with the supplied name. If the RDN is multi-value the first value is used.- Parameters:
name- of the RDN- Returns:
- RDN value
-
size
public int size()
Returns the number of RDNs in this DN.- Returns:
- number of RDNs
-
format
public java.lang.String format()
Produces a string representation of this DN.- Returns:
- DN string
-
format
public java.lang.String format(RDnNormalizer normalizer)
Produces a string representation of this DN.- Parameters:
normalizer- to apply to the RDN components or null for no formatting- Returns:
- DN string
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
builder
public static Dn.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-