Spring LDAP Framework

org.springframework.ldap.core
Class LdapRdn

java.lang.Object
  extended by org.springframework.ldap.core.LdapRdn
All Implemented Interfaces:
Serializable, Comparable

public class LdapRdn
extends Object
implements Serializable, Comparable

Datatype for a LDAP name, a part of a path. The name: uid=adam.skogman Key: uid Value: adam.skogman

Author:
Adam Skogman, Mattias Hellborg Arthursson
See Also:
Serialized Form

Constructor Summary
LdapRdn()
          Default constructor.
LdapRdn(String string)
          Parse the supplied string and construct this instance accordingly.
LdapRdn(String key, String value)
          Construct an LdapRdn using the supplied key and value.
 
Method Summary
 void addComponent(LdapRdnComponent rdnComponent)
          Add an LdapRdnComponent to this LdapRdn.
 int compareTo(Object obj)
          Compare this LdapRdn to another object.
 String encodeUrl()
          Get a String representation of this LdapRdn for use in urls.
 boolean equals(Object obj)
           
 LdapRdnComponent getComponent()
          Gets the first LdapRdnComponent of this LdapRdn.
 LdapRdnComponent getComponent(int idx)
          Get the LdapRdnComponent at index idx.
 List getComponents()
          Gets all components in this LdapRdn.
 String getKey()
          Get the key of this LdapRdn.
 String getLdapEncoded()
          Get a properly rfc2253-encoded String representation of this LdapRdn.
 String getValue()
          Get the value of this LdapRdn.
 String getValue(String key)
          Get the value of the LdapComponent with the specified key (Attribute name).
 int hashCode()
           
 LdapRdn immutableLdapRdn()
          Create an immutable copy of this instance.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LdapRdn

public LdapRdn()
Default constructor. Create an empty, uninitialized LdapRdn.


LdapRdn

public LdapRdn(String string)
Parse the supplied string and construct this instance accordingly.

Parameters:
string - the string to parse.

LdapRdn

public LdapRdn(String key,
               String value)
Construct an LdapRdn using the supplied key and value.

Parameters:
key - the attribute name.
value - the attribute value.
Method Detail

addComponent

public void addComponent(LdapRdnComponent rdnComponent)
Add an LdapRdnComponent to this LdapRdn.

Parameters:
rdnComponent - the LdapRdnComponent to add.s

getComponents

public List getComponents()
Gets all components in this LdapRdn.

Returns:
the List of all LdapRdnComponents composing this LdapRdn.

getComponent

public LdapRdnComponent getComponent()
Gets the first LdapRdnComponent of this LdapRdn.

Returns:
The first LdapRdnComponent of this LdapRdn.
Throws:
IndexOutOfBoundsException - if there are no components in this Rdn.

getComponent

public LdapRdnComponent getComponent(int idx)
Get the LdapRdnComponent at index idx.

Parameters:
idx - the 0-based index of the component to get.
Returns:
the LdapRdnComponent at index idx.
Throws:
IndexOutOfBoundsException - if there are no components in this Rdn.

getLdapEncoded

public String getLdapEncoded()
Get a properly rfc2253-encoded String representation of this LdapRdn.

Returns:
an escaped String corresponding to this LdapRdn.
Throws:
IndexOutOfBoundsException - if there are no components in this Rdn.

encodeUrl

public String encodeUrl()
Get a String representation of this LdapRdn for use in urls.

Returns:
a String representation of this LdapRdn for use in urls.

compareTo

public int compareTo(Object obj)
Compare this LdapRdn to another object.

Specified by:
compareTo in interface Comparable
Parameters:
obj - the object to compare to.
Throws:
ClassCastException - if the supplied object is not an LdapRdn instance.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getValue

public String getValue()
Get the value of this LdapRdn. Note that if this Rdn is multi-value the first value will be returned. E.g. for the Rdn cn=john doe+sn=doe, the return value would be john doe.

Returns:
the (first) value of this LdapRdn.
Throws:
IndexOutOfBoundsException - if there are no components in this Rdn.

getKey

public String getKey()
Get the key of this LdapRdn. Note that if this Rdn is multi-value the first key will be returned. E.g. for the Rdn cn=john doe+sn=doe, the return value would be cn.

Returns:
the (first) key of this LdapRdn.
Throws:
IndexOutOfBoundsException - if there are no components in this Rdn.

getValue

public String getValue(String key)
Get the value of the LdapComponent with the specified key (Attribute name).

Parameters:
key - the key
Returns:
the value.
Throws:
IllegalArgumentException - if there is no component with the specified key.

immutableLdapRdn

public LdapRdn immutableLdapRdn()
Create an immutable copy of this instance. It will not be possible to add or remove components or modify the keys and values of these components.

Returns:
an immutable copy of this instance.
Since:
1.3

Spring LDAP Framework

Copyright © 2005-2010 The Spring LDAP Framework. All Rights Reserved.