Package com.unboundid.ldap.sdk
Class Modification
- java.lang.Object
-
- com.unboundid.ldap.sdk.Modification
-
- All Implemented Interfaces:
java.io.Serializable
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class Modification extends java.lang.Object implements java.io.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Modification(ModificationType modificationType, java.lang.String attributeName)
Creates a new LDAP modification with the provided modification type and attribute name.Modification(ModificationType modificationType, java.lang.String attributeName, byte[] attributeValue)
Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, java.lang.String attributeName, byte[]... attributeValues)
Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, java.lang.String attributeName, ASN1OctetString[] attributeValues)
Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, java.lang.String attributeName, java.lang.String attributeValue)
Creates a new LDAP modification with the provided information.Modification(ModificationType modificationType, java.lang.String attributeName, java.lang.String... attributeValues)
Creates a new LDAP modification with the provided information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Modification
decode(ASN1Sequence modificationSequence)
Decodes the provided ASN.1 sequence as an LDAP modification.ASN1Sequence
encode()
Encodes this modification to an ASN.1 sequence suitable for use in the LDAP protocol.boolean
equals(java.lang.Object o)
Indicates whether the provided object is equal to this LDAP modification.Attribute
getAttribute()
Retrieves the attribute for this modification.java.lang.String
getAttributeName()
Retrieves the name of the attribute to target with this modification.ModificationType
getModificationType()
Retrieves the modification type for this modification.ASN1OctetString[]
getRawValues()
Retrieves the set of values for this modification as an array of ASN.1 octet strings.byte[][]
getValueByteArrays()
Retrieves the set of values for this modification as an array of byte arrays.java.lang.String[]
getValues()
Retrieves the set of values for this modification as an array of strings.int
hashCode()
Calculates a hash code for this LDAP modification.boolean
hasValue()
Indicates whether this modification has at least one value.static Modification
readFrom(ASN1StreamReader reader)
Reads and decodes an LDAP modification from the provided ASN.1 stream reader.void
toCode(java.util.List<java.lang.String> lineList, int indentSpaces, java.lang.String firstLinePrefix, java.lang.String lastLineSuffix)
Appends a number of lines comprising the Java source code that can be used to recreate this modification to the given list.java.lang.String
toString()
Retrieves a string representation of this LDAP modification.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP modification to the provided buffer.void
writeTo(ASN1Buffer buffer)
Writes an ASN.1-encoded representation of this modification to the provided ASN.1 buffer.
-
-
-
Constructor Detail
-
Modification
public Modification(ModificationType modificationType, java.lang.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 benull
.
-
Modification
public Modification(ModificationType modificationType, java.lang.String attributeName, java.lang.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(ModificationType modificationType, java.lang.String attributeName, 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(ModificationType modificationType, java.lang.String attributeName, java.lang.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(ModificationType modificationType, java.lang.String attributeName, 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(ModificationType modificationType, java.lang.String attributeName, 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 Detail
-
getModificationType
public ModificationType getModificationType()
Retrieves the modification type for this modification.- Returns:
- The modification type for this modification.
-
getAttribute
public Attribute getAttribute()
Retrieves the attribute for this modification.- Returns:
- The attribute for this modification.
-
getAttributeName
public java.lang.String 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, orfalse
if not.
-
getValues
public java.lang.String[] 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
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
public ASN1OctetString[] 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(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
public ASN1Sequence 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
public static Modification readFrom(ASN1StreamReader reader) throws LDAPException
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
public static Modification decode(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
public int hashCode()
Calculates a hash code for this LDAP modification.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The generated hash code for this LDAP modification.
-
equals
public boolean equals(java.lang.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 classjava.lang.Object
- Parameters:
o
- The object for which to make the determination.- Returns:
true
if the provided object is equal to this modification, orfalse
if not.
-
toString
public java.lang.String toString()
Retrieves a string representation of this LDAP modification.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this LDAP modification.
-
toString
public void toString(java.lang.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(java.util.List<java.lang.String> lineList, int indentSpaces, java.lang.String firstLinePrefix, java.lang.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 benull
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 benull
or empty if there should be no last line suffix.
-
-