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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addAttributeValue(java.lang.String name, java.lang.Object value)
Add a value to the Attribute with the specified name.void
addAttributeValue(java.lang.String name, java.lang.Object value, boolean addIfDuplicateExists)
Add a value to the Attribute with the specified name.boolean
attributeExists(java.lang.String name)
Check if an Object attribute exists, regardless of whether it has a value or not.javax.naming.directory.Attributes
getAttributes()
Get all the Attributes.java.util.SortedSet<java.lang.String>
getAttributeSortedStringSet(java.lang.String name)
Get all String values of the attribute as aSortedSet
.javax.naming.Name
getDn()
Returns the DN relative to the base path.java.lang.Object
getObjectAttribute(java.lang.String name)
Get the value of an Object attribute.java.lang.Object[]
getObjectAttributes(java.lang.String name)
Get all values of an Object attribute.java.lang.String
getStringAttribute(java.lang.String name)
Get the value of a String attribute.java.lang.String[]
getStringAttributes(java.lang.String name)
Get all values of a String attribute.void
removeAttributeValue(java.lang.String name, java.lang.Object value)
Remove a value from the Attribute with the specified name.void
setAttributeValue(java.lang.String name, java.lang.Object value)
Set the with the namename
to thevalue
.void
setAttributeValues(java.lang.String name, java.lang.Object[] values)
Sets a multivalue attribute, disregarding the order of the values.void
setAttributeValues(java.lang.String name, java.lang.Object[] values, boolean orderMatters)
Sets a multivalue attribute.
-
-
-
Method Detail
-
getStringAttribute
java.lang.String getStringAttribute(java.lang.String name)
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:
java.lang.ClassCastException
- if the value of the entry is not a String.
-
getObjectAttribute
java.lang.Object getObjectAttribute(java.lang.String name)
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
boolean attributeExists(java.lang.String name)
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
void setAttributeValue(java.lang.String name, java.lang.Object value)
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:
java.lang.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
void setAttributeValues(java.lang.String name, java.lang.Object[] values)
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:
java.lang.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
void setAttributeValues(java.lang.String name, java.lang.Object[] values, boolean orderMatters)
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:
java.lang.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
void addAttributeValue(java.lang.String name, java.lang.Object value)
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:
java.lang.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
void addAttributeValue(java.lang.String name, java.lang.Object value, boolean addIfDuplicateExists)
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:
java.lang.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
void removeAttributeValue(java.lang.String name, java.lang.Object value)
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:
java.lang.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
java.lang.String[] getStringAttributes(java.lang.String name)
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:
java.lang.IllegalArgumentException
- if any of the attribute values is not a String.
-
getObjectAttributes
java.lang.Object[] getObjectAttributes(java.lang.String name)
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
java.util.SortedSet<java.lang.String> getAttributeSortedStringSet(java.lang.String name)
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:
java.lang.IllegalArgumentException
- if one of the found attribute values cannot be cast to a String.
-
getDn
javax.naming.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:
DirContextAdapter.getNameInNamespace()
-
getAttributes
javax.naming.directory.Attributes getAttributes()
Get all the Attributes.- Returns:
- all the Attributes.
- Since:
- 1.3
-
-