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
  Author:
    Mattias Hellborg Arthursson

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `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.
    `Attributes` | `getAttributes()` Get all the Attributes.
    `SortedSet<String>` | `getAttributeSortedStringSet(String name)` Get all String values of the attribute as a `SortedSet`.
    `Name` | `getDn()` Returns the DN relative to the base path.
    `Object` | `getObjectAttribute(String name)` Get the value of an Object attribute.
    `Object[]` | `getObjectAttributes(String name)` Get all values of an Object attribute.
    `String` | `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 name `name` to the `value`.
    `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 Detail

    - #### getStringAttribute

          String getStringAttribute(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:
        `ClassCastException` - if the value of the entry is not a String.

    - #### getObjectAttribute

          Object getObjectAttribute(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(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(String name,
                                 Object value)

      Set the with the name `name` to the `value`. If the value is a `Name` 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 a `Name` instance and one or several of the currently present attribute values is not `Name` instances or Strings representing valid Distinguished Names.

    - #### setAttributeValues

          void setAttributeValues(String name,
                                  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 are `Name` 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 a `Name` instance and one or several of the currently present attribute values is not `Name` instances or Strings representing valid Distinguished Names.

    - #### setAttributeValues

          void setAttributeValues(String name,
                                  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 are `Name` instances, equality for Distinguished Names will be used for calculating attribute modifications.
      Parameters:
        `name` - The id of the attribute.
        `values` - Attribute values.
        `orderMatters` - If `true`, it will be changed even if data was just reordered.
      Throws:
        `IllegalArgumentException` - if value is a `Name` instance and one or several of the currently present attribute values is not `Name` instances or Strings representing valid Distinguished Names.

    - #### addAttributeValue

          void addAttributeValue(String name,
                                 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 a `Name` 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 a `Name` instance and one or several of the currently present attribute values is not `Name` instances or Strings representing valid Distinguished Names.

    - #### addAttributeValue

          void addAttributeValue(String name,
                                 Object value,
                                 boolean addIfDuplicateExists)

      Add a value to the Attribute with the specified name. If the Attribute doesn't exist it will be created. The `addIfDuplicateExists` parameter controls the handling of duplicates. It `false`, 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 a `Name` 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 a `Name` instance and one or several of the currently present attribute values is not `Name` instances or Strings representing valid Distinguished Names.

    - #### removeAttributeValue

          void removeAttributeValue(String name,
                                    Object value)

      Remove a value from the Attribute with the specified name. If the Attribute doesn't exist, do nothing. If the value is a `Name` 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 a `Name` instance and one or several of the currently present attribute values is not `Name` instances or Strings representing valid Distinguished Names.

    - #### getStringAttributes

          String[] getStringAttributes(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:
        `IllegalArgumentException` - if any of the attribute values is not a String.

    - #### getObjectAttributes

          Object[] getObjectAttributes(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

          SortedSet<String> getAttributeSortedStringSet(String name)

      Get all String values of the attribute as a `SortedSet`.
      Parameters:
        `name` - name of the attribute.
      Returns:
        a `SortedSet` containing all values of the attribute, or `null` 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:
        `DirContextAdapter.getNameInNamespace()`

    - #### getAttributes

          Attributes getAttributes()

      Get all the Attributes.
      Returns:
        all the Attributes.
      Since:
        1.3