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 TypeMethodDescriptionvoidaddAttributeValue(String name, Object value) Add a value to the Attribute with the specified name.voidaddAttributeValue(String name, Object value, boolean addIfDuplicateExists) Add a value to the Attribute with the specified name.booleanattributeExists(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.voidremoveAttributeValue(String name, Object value) Remove a value from the Attribute with the specified name.voidsetAttributeValue(String name, Object value) Set the with the namenameto thevalue.voidsetAttributeValues(String name, Object[] values) Sets a multivalue attribute, disregarding the order of the values.voidsetAttributeValues(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,nullwill be returned.- Parameters:
name- name of the attribute.- Returns:
- the value of the attribute if it exists, or
nullif 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,nullwill be returned.- Parameters:
name- name of the attribute.- Returns:
- the attribute value as an object if it exists, or
nullif 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:
trueif the attribute exists,falseotherwise
-
setAttributeValue
Set the with the namenameto thevalue. If the value is aNameinstance, 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 aNameinstance and one or several of the currently present attribute values is notNameinstances 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 areNameinstances, 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 aNameinstance and one or several of the currently present attribute values is notNameinstances 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 areNameinstances, 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 aNameinstance and one or several of the currently present attribute values is notNameinstances 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 aNameinstance, 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 aNameinstance and one or several of the currently present attribute values is notNameinstances 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. TheaddIfDuplicateExistsparameter 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 aNameinstance, 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-truewill add the value regardless of whether there is an identical value already, allowing for duplicate attribute values;falsewill not add the value if it already exists.- Throws:
IllegalArgumentException- if value is aNameinstance and one or several of the currently present attribute values is notNameinstances 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 aNameinstance, 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 aNameinstance and one or several of the currently present attribute values is notNameinstances 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
nullotherwise. - 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
nullotherwise. - Since:
- 1.3
-
getAttributeSortedStringSet
Get all String values of the attribute as aSortedSet.- Parameters:
name- name of the attribute.- Returns:
- a
SortedSetcontaining all values of the attribute, ornullif 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
-