Package com.unboundid.ldap.sdk
Class Modification
java.lang.Object
com.unboundid.ldap.sdk.Modification
- All Implemented Interfaces:
Serializable
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class Modification
extends Object
implements 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 Summary
ConstructorsConstructorDescriptionModification(ModificationType modificationType, String attributeName) Creates a new LDAP modification with the provided modification type and attribute name.Modification(ModificationType modificationType, String attributeName, byte[] attributeValue) Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, String attributeName, byte[]... attributeValues) Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, String attributeName, ASN1OctetString[] attributeValues) Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, String attributeName, String attributeValue) Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, String attributeName, String... attributeValues) Creates a new LDAP modification with the provided information. -
Method Summary
Modifier and TypeMethodDescriptionstatic Modificationdecode(ASN1Sequence modificationSequence) Decodes the provided ASN.1 sequence as an LDAP modification.encode()Encodes this modification to an ASN.1 sequence suitable for use in the LDAP protocol.booleanIndicates whether the provided object is equal to this LDAP modification.Retrieves the attribute for this modification.Retrieves the name of the attribute to target with this modification.Retrieves the modification type for this modification.Retrieves the set of values for this modification as an array of ASN.1 octet strings.byte[][]Retrieves the set of values for this modification as an array of byte arrays.String[]Retrieves the set of values for this modification as an array of strings.inthashCode()Calculates a hash code for this LDAP modification.booleanhasValue()Indicates whether this modification has at least one value.static ModificationreadFrom(ASN1StreamReader reader) Reads and decodes an LDAP modification from the provided ASN.1 stream reader.voidAppends a number of lines comprising the Java source code that can be used to recreate this modification to the given list.toString()Retrieves a string representation of this LDAP modification.voidtoString(StringBuilder buffer) Appends a string representation of this LDAP modification to the provided buffer.voidwriteTo(ASN1Buffer buffer) Writes an ASN.1-encoded representation of this modification to the provided ASN.1 buffer.
-
Constructor Details
-
Modification
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 benull.
-
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 benull.attributeValue- The attribute value for this modification. It must not benull.
-
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 benull.attributeValue- The attribute value for this modification. It must not benull.
-
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 benull.attributeValues- The set of attribute value for this modification. It must not benull.
-
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 benull.attributeValues- The set of attribute value for this modification. It must not benull.
-
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 benull.attributeValues- The set of attribute value for this modification. It must not benull.
-
-
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
Indicates whether this modification has at least one value.- Returns:
trueif this modification has one or more values, orfalseif 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
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
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 benull.- 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
Calculates a hash code for this LDAP modification. -
equals
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. -
toString
Retrieves a string representation of this LDAP modification. -
toString
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 benullor 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 benullor empty if there should be no last line suffix.
-