Package org.ldaptive
Class LdapEntry
- java.lang.Object
-
- org.ldaptive.AbstractLdapBean
-
- org.ldaptive.LdapEntry
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SearchEntry
public class LdapEntry extends AbstractLdapBean
Simple bean representing an ldap entry. Contains a DN and ldap attributes.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,LdapAttribute>
entryAttributes
Attributes contained in this bean.private String
entryDn
Distinguished name for this entry.private static int
HASH_CODE_SEED
hash code seed.private static long
serialVersionUID
serial version uid.
-
Constructor Summary
Constructors Constructor Description LdapEntry()
Default constructor.LdapEntry(String dn)
Creates a new ldap entry.LdapEntry(String dn, Collection<LdapAttribute> attrs)
Creates a new ldap entry.LdapEntry(String dn, LdapAttribute... attr)
Creates a new ldap entry.LdapEntry(SortBehavior sb)
Creates a new ldap entry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(LdapAttribute... attr)
Adds an attribute to this ldap attributes.void
addAttributes(Collection<LdapAttribute> attrs)
Adds attribute(s) to this ldap attributes.void
clear()
Removes all the attributes in this ldap attributes.static AttributeModification[]
computeModifications(LdapEntry source, LdapEntry target)
Returns the list of attribute modifications needed to change the supplied target entry into the supplied source entry.boolean
equals(Object o)
LdapAttribute
getAttribute()
Returns a single attribute of this attributes.LdapAttribute
getAttribute(String name)
Returns the attribute with the supplied name.String[]
getAttributeNames()
Returns the attribute names in this entry.Collection<LdapAttribute>
getAttributes()
Returns a collection of ldap attribute.String
getDn()
Returns the DN.int
hashCode()
void
removeAttribute(String name)
Removes the attribute of the supplied name from this ldap attributes.void
removeAttribute(LdapAttribute... attr)
Removes an attribute from this ldap attributes.void
removeAttributes(Collection<LdapAttribute> attrs)
Removes the attribute(s) from this ldap attributes.void
renameAttribute(String oldName, String newName)
Changes the name of an attribute in this entry.void
setDn(String dn)
Sets the DN.int
size()
Returns the number of attributes in this ldap attributes.String
toString()
-
Methods inherited from class org.ldaptive.AbstractLdapBean
getSortBehavior
-
-
-
-
Field Detail
-
HASH_CODE_SEED
private static final int HASH_CODE_SEED
hash code seed.- See Also:
- Constant Field Values
-
serialVersionUID
private static final long serialVersionUID
serial version uid.- See Also:
- Constant Field Values
-
entryDn
private String entryDn
Distinguished name for this entry.
-
entryAttributes
private final Map<String,LdapAttribute> entryAttributes
Attributes contained in this bean.
-
-
Constructor Detail
-
LdapEntry
public LdapEntry()
Default constructor.
-
LdapEntry
public LdapEntry(SortBehavior sb)
Creates a new ldap entry.- Parameters:
sb
- sort behavior
-
LdapEntry
public LdapEntry(String dn)
Creates a new ldap entry.- Parameters:
dn
- dn for this entry
-
LdapEntry
public LdapEntry(String dn, LdapAttribute... attr)
Creates a new ldap entry.- Parameters:
dn
- dn for this entryattr
- ldap attribute for this entry
-
LdapEntry
public LdapEntry(String dn, Collection<LdapAttribute> attrs)
Creates a new ldap entry.- Parameters:
dn
- dn for this entryattrs
- collection of attributes to add
-
-
Method Detail
-
getDn
public String getDn()
Returns the DN.- Returns:
- entry DN
-
setDn
public void setDn(String dn)
Sets the DN.- Parameters:
dn
- dn to set
-
getAttributes
public Collection<LdapAttribute> getAttributes()
Returns a collection of ldap attribute.- Returns:
- collection of ldap attribute
-
getAttribute
public LdapAttribute getAttribute()
Returns a single attribute of this attributes. If multiple attributes exist the first attribute returned by the underlying iterator is used. If no attributes exist null is returned.- Returns:
- single attribute
-
getAttribute
public LdapAttribute getAttribute(String name)
Returns the attribute with the supplied name.- Parameters:
name
- of the attribute to return- Returns:
- ldap attribute
-
getAttributeNames
public String[] getAttributeNames()
Returns the attribute names in this entry.- Returns:
- string array of attribute names
-
addAttribute
public void addAttribute(LdapAttribute... attr)
Adds an attribute to this ldap attributes.- Parameters:
attr
- attribute to add
-
addAttributes
public void addAttributes(Collection<LdapAttribute> attrs)
Adds attribute(s) to this ldap attributes.- Parameters:
attrs
- collection of attributes to add
-
removeAttribute
public void removeAttribute(LdapAttribute... attr)
Removes an attribute from this ldap attributes.- Parameters:
attr
- attribute to remove
-
removeAttribute
public void removeAttribute(String name)
Removes the attribute of the supplied name from this ldap attributes.- Parameters:
name
- of attribute to remove
-
removeAttributes
public void removeAttributes(Collection<LdapAttribute> attrs)
Removes the attribute(s) from this ldap attributes.- Parameters:
attrs
- collection of ldap attributes to remove
-
renameAttribute
public void renameAttribute(String oldName, String newName)
Changes the name of an attribute in this entry. The old attribute is removed from this entry, the name is changed withLdapAttribute.setName(String)
, and the attribute is added back to this entry. If oldName does not exist, this method does nothing.- Parameters:
oldName
- attribute name to change fromnewName
- attribute name to change to
-
size
public int size()
Returns the number of attributes in this ldap attributes.- Returns:
- number of attributes in this ldap attributes
-
clear
public void clear()
Removes all the attributes in this ldap attributes.
-
computeModifications
public static AttributeModification[] computeModifications(LdapEntry source, LdapEntry target)
Returns the list of attribute modifications needed to change the supplied target entry into the supplied source entry.- Parameters:
source
- ldap entry containing new datatarget
- ldap entry containing existing data- Returns:
- attribute modifications needed to change target into source or an empty array
-
-