Class Modification

java.lang.Object
com.unboundid.ldap.sdk.Modification
All Implemented Interfaces:
Serializable

This class provides a data structure for holding information about an LDAP modification, which describes a change to apply to an attribute. A modification includes the following elements:
  • A modification type, which describes the type of change to apply.
  • An attribute name, which specifies which attribute should be updated.
  • An optional set of values to use for the modification.
See Also:
  • Constructor Details

    • Modification

      public Modification(@NotNull ModificationType modificationType, @NotNull String attributeName)
      Creates a new LDAP modification with the provided modification type and attribute name. It will not have any values.
      Parameters:
      modificationType - The modification type for this modification.
      attributeName - The name of the attribute to target with this modification. It must not be null.
    • Modification

      public Modification(@NotNull ModificationType modificationType, @NotNull String attributeName, @NotNull String attributeValue)
      Creates a new LDAP modification with the provided information.
      Parameters:
      modificationType - The modification type for this modification.
      attributeName - The name of the attribute to target with this modification. It must not be null.
      attributeValue - The attribute value for this modification. It must not be null.
    • Modification

      public Modification(@NotNull ModificationType modificationType, @NotNull String attributeName, @NotNull byte[] attributeValue)
      Creates a new LDAP modification with the provided information.
      Parameters:
      modificationType - The modification type for this modification.
      attributeName - The name of the attribute to target with this modification. It must not be null.
      attributeValue - The attribute value for this modification. It must not be null.
    • Modification

      public Modification(@NotNull ModificationType modificationType, @NotNull String attributeName, @NotNull String... attributeValues)
      Creates a new LDAP modification with the provided information.
      Parameters:
      modificationType - The modification type for this modification.
      attributeName - The name of the attribute to target with this modification. It must not be null.
      attributeValues - The set of attribute value for this modification. It must not be null.
    • Modification

      public Modification(@NotNull ModificationType modificationType, @NotNull String attributeName, @NotNull byte[]... attributeValues)
      Creates a new LDAP modification with the provided information.
      Parameters:
      modificationType - The modification type for this modification.
      attributeName - The name of the attribute to target with this modification. It must not be null.
      attributeValues - The set of attribute value for this modification. It must not be null.
    • Modification

      public Modification(@NotNull ModificationType modificationType, @NotNull String attributeName, @NotNull ASN1OctetString[] attributeValues)
      Creates a new LDAP modification with the provided information.
      Parameters:
      modificationType - The modification type for this modification.
      attributeName - The name of the attribute to target with this modification. It must not be null.
      attributeValues - The set of attribute value for this modification. It must not be null.
  • Method Details

    • getModificationType

      Retrieves the modification type for this modification.
      Returns:
      The modification type for this modification.
    • getAttribute

      Retrieves the attribute for this modification.
      Returns:
      The attribute for this modification.
    • getAttributeName

      Retrieves the name of the attribute to target with this modification.
      Returns:
      The name of the attribute to target with this modification.
    • hasValue

      public boolean hasValue()
      Indicates whether this modification has at least one value.
      Returns:
      true if this modification has one or more values, or false if not.
    • getValues

      Retrieves the set of values for this modification as an array of strings.
      Returns:
      The set of values for this modification as an array of strings.
    • getValueByteArrays

      @NotNull public byte[][] getValueByteArrays()
      Retrieves the set of values for this modification as an array of byte arrays.
      Returns:
      The set of values for this modification as an array of byte arrays.
    • getRawValues

      Retrieves the set of values for this modification as an array of ASN.1 octet strings.
      Returns:
      The set of values for this modification as an array of ASN.1 octet strings.
    • writeTo

      public void writeTo(@NotNull ASN1Buffer buffer)
      Writes an ASN.1-encoded representation of this modification to the provided ASN.1 buffer.
      Parameters:
      buffer - The ASN.1 buffer to which the encoded representation should be written.
    • encode

      Encodes this modification to an ASN.1 sequence suitable for use in the LDAP protocol.
      Returns:
      An ASN.1 sequence containing the encoded value.
    • readFrom

      Reads and decodes an LDAP modification from the provided ASN.1 stream reader.
      Parameters:
      reader - The ASN.1 stream reader from which to read the modification.
      Returns:
      The decoded modification.
      Throws:
      LDAPException - If a problem occurs while trying to read or decode the modification.
    • decode

      @NotNull public static Modification decode(@NotNull ASN1Sequence modificationSequence) throws LDAPException
      Decodes the provided ASN.1 sequence as an LDAP modification.
      Parameters:
      modificationSequence - The ASN.1 sequence to decode as an LDAP modification. It must not be null.
      Returns:
      The decoded LDAP modification.
      Throws:
      LDAPException - If a problem occurs while trying to decode the provided ASN.1 sequence as an LDAP modification.
    • hashCode

      public int hashCode()
      Calculates a hash code for this LDAP modification.
      Overrides:
      hashCode in class Object
      Returns:
      The generated hash code for this LDAP modification.
    • equals

      public boolean equals(@Nullable Object o)
      Indicates whether the provided object is equal to this LDAP modification. The provided object will only be considered equal if it is an LDAP modification with the same modification type, attribute name, and set of values as this LDAP modification.
      Overrides:
      equals in class Object
      Parameters:
      o - The object for which to make the determination.
      Returns:
      true if the provided object is equal to this modification, or false if not.
    • toString

      Retrieves a string representation of this LDAP modification.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this LDAP modification.
    • toString

      public void toString(@NotNull StringBuilder buffer)
      Appends a string representation of this LDAP modification to the provided buffer.
      Parameters:
      buffer - The buffer to which to append the string representation of this LDAP modification.
    • toCode

      public void toCode(@NotNull List<String> lineList, int indentSpaces, @Nullable String firstLinePrefix, @Nullable String lastLineSuffix)
      Appends a number of lines comprising the Java source code that can be used to recreate this modification to the given list. Note that unless a first line prefix and/or last line suffix are provided, this will just include the code for the constructor, starting with "new Modification(" and ending with the closing parenthesis for that constructor.
      Parameters:
      lineList - The list to which the source code lines should be added.
      indentSpaces - The number of spaces that should be used to indent the generated code. It must not be negative.
      firstLinePrefix - An optional string that should precede "new Modification(" on the first line of the generated code (e.g., it could be used for an attribute assignment, like "Modification m = "). It may be null or empty if there should be no first line prefix.
      lastLineSuffix - An optional suffix that should follow the closing parenthesis of the constructor (e.g., it could be a semicolon to represent the end of a Java statement or a comma to separate it from another element in an array). It may be null or empty if there should be no last line suffix.