Package org.springframework
Interface LdapDataEntry
- All Known Subinterfaces:
DirContextOperations
- All Known Implementing Classes:
DirContextAdapter
public interface LdapDataEntry
Common data access methods for entries in an LDAP tree.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttributeValue
(String name, Object value) Add a value to the Attribute with the specified name.void
addAttributeValue
(String name, Object value, boolean addIfDuplicateExists) Add a value to the Attribute with the specified name.boolean
attributeExists
(String name) Check if an Object attribute exists, regardless of whether it has a value or not.Get all the Attributes.Get all String values of the attribute as aSortedSet
.getDn()
Returns the DN relative to the base path.getObjectAttribute
(String name) Get the value of an Object attribute.Object[]
getObjectAttributes
(String name) Get all values of an Object attribute.getStringAttribute
(String name) Get the value of a String attribute.String[]
getStringAttributes
(String name) Get all values of a String attribute.void
removeAttributeValue
(String name, Object value) Remove a value from the Attribute with the specified name.void
setAttributeValue
(String name, Object value) Set the with the namename
to thevalue
.void
setAttributeValues
(String name, Object[] values) Sets a multivalue attribute, disregarding the order of the values.void
setAttributeValues
(String name, Object[] values, boolean orderMatters) Sets a multivalue attribute.
-
Method Details
-
getStringAttribute
Get the value of a String attribute. If more than one attribute value exists for the specified attribute, only the first one will be returned. If an attribute has no value,null
will be returned.- Parameters:
name
- name of the attribute.- Returns:
- the value of the attribute if it exists, or
null
if the attribute doesn't exist or if it exists but with no value. - Throws:
ClassCastException
- if the value of the entry is not a String.
-
getObjectAttribute
Get the value of an Object attribute. If more than one attribute value exists for the specified attribute, only the first one will be returned. If an attribute has no value,null
will be returned.- Parameters:
name
- name of the attribute.- Returns:
- the attribute value as an object if it exists, or
null
if the attribute doesn't exist or if it exists but with no value.
-
attributeExists
Check if an Object attribute exists, regardless of whether it has a value or not.- Parameters:
name
- name of the attribute- Returns:
true
if the attribute exists,false
otherwise
-
setAttributeValue
Set the with the namename
to thevalue
. If the value is aName
instance, equality for Distinguished Names will be used for calculating attribute modifications.- Parameters:
name
- name of the attribute.value
- value to set the attribute to.- Throws:
IllegalArgumentException
- if the value is aName
instance and one or several of the currently present attribute values is notName
instances or Strings representing valid Distinguished Names.
-
setAttributeValues
Sets a multivalue attribute, disregarding the order of the values. If value is null or value.length == 0 then the attribute will be removed. If update mode, changes will be made only if the array has more or less objects or if one or more object has changed. Reordering the objects will not cause an update. If the values areName
instances, equality for Distinguished Names will be used for calculating attribute modifications.- Parameters:
name
- The id of the attribute.values
- Attribute values.- Throws:
IllegalArgumentException
- if value is aName
instance and one or several of the currently present attribute values is notName
instances or Strings representing valid Distinguished Names.
-
setAttributeValues
Sets a multivalue attribute. If value is null or value.length == 0 then the attribute will be removed. If update mode, changes will be made if the array has more or less objects or if one or more string has changed. Reordering the objects will only cause an update if orderMatters is set to true. If the values areName
instances, equality for Distinguished Names will be used for calculating attribute modifications.- Parameters:
name
- The id of the attribute.values
- Attribute values.orderMatters
- Iftrue
, it will be changed even if data was just reordered.- Throws:
IllegalArgumentException
- if value is aName
instance and one or several of the currently present attribute values is notName
instances or Strings representing valid Distinguished Names.
-
addAttributeValue
Add a value to the Attribute with the specified name. If the Attribute doesn't exist it will be created. This method makes sure that the there will be no duplicates of an added value - it the value exists it will not be added again. If the value is aName
instance, equality for Distinguished Names will be used for calculating attribute modifications.- Parameters:
name
- the name of the Attribute to which the specified value should be added.value
- the Attribute value to add.- Throws:
IllegalArgumentException
- if value is aName
instance and one or several of the currently present attribute values is notName
instances or Strings representing valid Distinguished Names.
-
addAttributeValue
Add a value to the Attribute with the specified name. If the Attribute doesn't exist it will be created. TheaddIfDuplicateExists
parameter controls the handling of duplicates. Itfalse
, this method makes sure that the there will be no duplicates of an added value - it the value exists it will not be added again. If the value is aName
instance, equality for Distinguished Names will be used for calculating attribute modifications.- Parameters:
name
- the name of the Attribute to which the specified value should be added.value
- the Attribute value to add.addIfDuplicateExists
-true
will add the value regardless of whether there is an identical value already, allowing for duplicate attribute values;false
will not add the value if it already exists.- Throws:
IllegalArgumentException
- if value is aName
instance and one or several of the currently present attribute values is notName
instances or Strings representing valid Distinguished Names.
-
removeAttributeValue
Remove a value from the Attribute with the specified name. If the Attribute doesn't exist, do nothing. If the value is aName
instance, equality for Distinguished Names will be used for calculating attribute modifications.- Parameters:
name
- the name of the Attribute from which the specified value should be removed.value
- the value to remove.- Throws:
IllegalArgumentException
- if value is aName
instance and one or several of the currently present attribute values is notName
instances or Strings representing valid Distinguished Names.
-
getStringAttributes
Get all values of a String attribute.- Parameters:
name
- name of the attribute.- Returns:
- a (possibly empty) array containing all registered values of the attribute
as Strings if the attribute is defined or
null
otherwise. - Throws:
IllegalArgumentException
- if any of the attribute values is not a String.
-
getObjectAttributes
Get all values of an Object attribute.- Parameters:
name
- name of the attribute.- Returns:
- a (possibly empty) array containing all registered values of the attribute
if the attribute is defined or
null
otherwise. - Since:
- 1.3
-
getAttributeSortedStringSet
Get all String values of the attribute as aSortedSet
.- Parameters:
name
- name of the attribute.- Returns:
- a
SortedSet
containing all values of the attribute, ornull
if the attribute does not exist. - Throws:
IllegalArgumentException
- if one of the found attribute values cannot be cast to a String.
-
getDn
Name getDn()Returns the DN relative to the base path. NB: as of version 2.0 the returned name will be an LdapName instance.- Returns:
- The distinguished name of the current context.
- See Also:
-
getAttributes
Attributes getAttributes()Get all the Attributes.- Returns:
- all the Attributes.
- Since:
- 1.3
-