Package com.unboundid.ldap.sdk
Class Entry
java.lang.Object
com.unboundid.ldap.sdk.Entry
- All Implemented Interfaces:
LDIFRecord,Serializable
- Direct Known Subclasses:
ReadOnlyEntry
@Mutable
@NotExtensible
@ThreadSafety(level=NOT_THREADSAFE)
public class Entry
extends Object
implements LDIFRecord
This class provides a data structure for holding information about an LDAP
entry. An entry contains a distinguished name (DN) and a set of attributes.
An entry can be created from these components, and it can also be created
from its LDIF representation as described in
RFC 2849. For example:
This class also provides methods for retrieving the LDIF representation of an entry, either as a single string or as an array of strings that make up the LDIF lines.
The
Entry objects are mutable, and the DN, set of attributes, and individual attribute values can be altered.
Entry entry = new Entry(
"dn: dc=example,dc=com",
"objectClass: top",
"objectClass: domain",
"dc: example");
This class also provides methods for retrieving the LDIF representation of an entry, either as a single string or as an array of strings that make up the LDIF lines.
The
diff(com.unboundid.ldap.sdk.Entry, com.unboundid.ldap.sdk.Entry, boolean, java.lang.String...) method may be used to obtain the set of differences
between two entries, and to retrieve a list of Modification objects
that can be used to modify one entry so that it contains the same set of
data as another. The applyModifications(com.unboundid.ldap.sdk.Entry, boolean, com.unboundid.ldap.sdk.Modification...) method may be used to
apply a set of modifications to an entry.
Entry objects are mutable, and the DN, set of attributes, and individual attribute values can be altered.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new entry with the provided DN and no attributes.Creates a new entry with the provided DN and set of attributes.Creates a new entry with the provided DN and no attributes.Creates a new entry with the provided DN and set of attributes.Entry(DN dn, Schema schema, Collection<Attribute> attributes) Creates a new entry with the provided DN and set of attributes.Entry(DN dn, Collection<Attribute> attributes) Creates a new entry with the provided DN and set of attributes.protectedCreates a new entry that wraps the provided entry.Creates a new entry from the provided LDIF representation.Creates a new entry with the provided DN and no attributes.Creates a new entry from the provided LDIF representation.Creates a new entry with the provided DN and set of attributes.Creates a new entry with the provided DN and no attributes.Creates a new entry with the provided DN and set of attributes.Entry(String dn, Schema schema, Collection<Attribute> attributes) Creates a new entry with the provided DN and set of attributes.Entry(String dn, Collection<Attribute> attributes) Creates a new entry with the provided DN and set of attributes. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAttribute(Attribute attribute) Adds the provided attribute to this entry.booleanaddAttribute(String attributeName, byte[] attributeValue) Adds the specified attribute value to this entry, if it is not already present.booleanaddAttribute(String attributeName, byte[]... attributeValues) Adds the provided attribute to this entry.booleanaddAttribute(String attributeName, String attributeValue) Adds the specified attribute value to this entry, if it is not already present.booleanaddAttribute(String attributeName, String... attributeValues) Adds the provided attribute to this entry.booleanaddAttribute(String attributeName, Collection<String> attributeValues) Adds the provided attribute to this entry.static EntryapplyModifications(Entry entry, boolean lenient, Modification... modifications) Creates a duplicate of the provided entry with the given set of modifications applied to it.static EntryapplyModifications(Entry entry, boolean lenient, List<Modification> modifications) Creates a duplicate of the provided entry with the given set of modifications applied to it.static EntryapplyModifyDN(Entry entry, String newRDN, boolean deleteOldRDN) Creates a duplicate of the provided entry with the appropriate changes for a modify DN operation.static EntryapplyModifyDN(Entry entry, String newRDN, boolean deleteOldRDN, String newSuperiorDN) Creates a duplicate of the provided entry with the appropriate changes for a modify DN operation.static List<Modification> diff(Entry sourceEntry, Entry targetEntry, boolean ignoreRDN, boolean reversible, boolean byteForByte, String... attributes) Retrieves a set of modifications that can be applied to the source entry in order to make it match the target entry.static List<Modification> diff(Entry sourceEntry, Entry targetEntry, boolean ignoreRDN, boolean reversible, String... attributes) Retrieves a set of modifications that can be applied to the source entry in order to make it match the target entry.static List<Modification> Retrieves a set of modifications that can be applied to the source entry in order to make it match the target entry.Creates a new entry that is a duplicate of this entry.booleanIndicates whether the provided object is equal to this entry.final AttributegetAttribute(String attributeName) Retrieves the attribute with the specified name.final AttributegetAttribute(String attributeName, Schema schema) Retrieves the attribute with the specified name.final Collection<Attribute> Retrieves the set of attributes contained in this entry.getAttributesWithOptions(String baseName, Set<String> options) Retrieves the list of attributes with the given base name and all of the specified options.getAttributeValue(String attributeName) Retrieves the value for the specified attribute, if available.getAttributeValueAsBoolean(String attributeName) Retrieves the value for the specified attribute as a Boolean, if available.getAttributeValueAsDate(String attributeName) Retrieves the value for the specified attribute as a Date, formatted using the generalized time syntax, if available.getAttributeValueAsDN(String attributeName) Retrieves the value for the specified attribute as a DN, if available.getAttributeValueAsInteger(String attributeName) Retrieves the value for the specified attribute as an Integer, if available.getAttributeValueAsLong(String attributeName) Retrieves the value for the specified attribute as a Long, if available.byte[][]getAttributeValueByteArrays(String attributeName) Retrieves the set of values for the specified attribute as byte arrays, if available.byte[]getAttributeValueBytes(String attributeName) Retrieves the value for the specified attribute as a byte array, if available.String[]getAttributeValues(String attributeName) Retrieves the set of values for the specified attribute, if available.final StringgetDN()Retrieves the DN for this entry.final AttributeRetrieves the "objectClass" attribute from the entry, if available.final String[]Retrieves the values of the "objectClass" attribute from the entry, if available.final DNRetrieves the parent DN for this entry.final StringRetrieves the parent DN for this entry as a string.final DNRetrieves the parsed DN for this entry.final RDNgetRDN()Retrieves the RDN for this entry.protected SchemaRetrieves the schema that will be used for this entry, if any.final booleanhasAttribute(Attribute attribute) Indicates whether this entry contains the specified attribute.final booleanhasAttribute(String attributeName) Indicates whether this entry contains the specified attribute.final booleanhasAttribute(String attributeName, Schema schema) Indicates whether this entry contains the specified attribute.final booleanhasAttributeValue(String attributeName, byte[] attributeValue) Indicates whether this entry contains an attribute with the given name and value.final booleanhasAttributeValue(String attributeName, byte[] attributeValue, MatchingRule matchingRule) Indicates whether this entry contains an attribute with the given name and value.final booleanhasAttributeValue(String attributeName, String attributeValue) Indicates whether this entry contains an attribute with the given name and value.final booleanhasAttributeValue(String attributeName, String attributeValue, MatchingRule matchingRule) Indicates whether this entry contains an attribute with the given name and value.inthashCode()Generates a hash code for this entry.final booleanhasObjectClass(String objectClassName) Indicates whether this entry contains the specified object class.static EntryintersectEntries(Entry... entries) Intersects the contents of all provided entries so that the resulting entry will contain only attribute values present in all of the provided entries.booleanmatchesBaseAndScope(DN baseDN, SearchScope scope) Indicates whether this entry falls within the range of the provided search base DN and scope.booleanmatchesBaseAndScope(String baseDN, SearchScope scope) Indicates whether this entry falls within the range of the provided search base DN and scope.static EntrymergeEntries(Entry... entries) Merges the contents of all provided entries so that the resulting entry will contain all attribute values present in at least one of the entries.booleanremoveAttribute(String attributeName) Removes the specified attribute from this entry.booleanremoveAttributeValue(String attributeName, byte[] attributeValue) Removes the specified attribute value from this entry if it is present.booleanremoveAttributeValue(String attributeName, byte[] attributeValue, MatchingRule matchingRule) Removes the specified attribute value from this entry if it is present.booleanremoveAttributeValue(String attributeName, String attributeValue) Removes the specified attribute value from this entry if it is present.booleanremoveAttributeValue(String attributeName, String attributeValue, MatchingRule matchingRule) Removes the specified attribute value from this entry if it is present.booleanremoveAttributeValues(String attributeName, byte[]... attributeValues) Removes the specified attribute values from this entry if they are present.booleanremoveAttributeValues(String attributeName, String... attributeValues) Removes the specified attribute values from this entry if they are present.voidsetAttribute(Attribute attribute) Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.voidsetAttribute(String attributeName, byte[] attributeValue) Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.voidsetAttribute(String attributeName, byte[]... attributeValues) Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.voidsetAttribute(String attributeName, String attributeValue) Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.voidsetAttribute(String attributeName, String... attributeValues) Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.voidsetAttribute(String attributeName, Collection<String> attributeValues) Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.voidSpecifies the DN for this entry.voidSpecifies the DN for this entry.final String[]toLDIF()Retrieves an LDIF representation of this entry, with each attribute value on a separate line.final String[]toLDIF(int wrapColumn) Retrieves an LDIF representation of this entry, with each attribute value on a separate line.final voidtoLDIF(ByteStringBuffer buffer) Appends an LDIF representation of this entry to the provided buffer.final voidtoLDIF(ByteStringBuffer buffer, int wrapColumn) Appends an LDIF representation of this entry to the provided buffer.final StringRetrieves an LDIF-formatted string representation of this entry.final StringtoLDIFString(int wrapColumn) Retrieves an LDIF-formatted string representation of this entry.final voidtoLDIFString(StringBuilder buffer) Appends an LDIF-formatted string representation of this entry to the provided buffer.final voidtoLDIFString(StringBuilder buffer, int wrapColumn) Appends an LDIF-formatted string representation of this entry to the provided buffer.final StringtoString()Retrieves a string representation of this entry.voidtoString(StringBuilder buffer) Appends a string representation of this entry to the provided buffer.
-
Constructor Details
-
Entry
Creates a new entry that wraps the provided entry.- Parameters:
e- The entry to be wrapped.
-
Entry
Creates a new entry with the provided DN and no attributes.- Parameters:
dn- The DN for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and no attributes.- Parameters:
dn- The DN for this entry. It must not benull.schema- The schema to use for operations involving this entry. It may benullif no schema is available.
-
Entry
Creates a new entry with the provided DN and no attributes.- Parameters:
dn- The DN for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and no attributes.- Parameters:
dn- The DN for this entry. It must not benull.schema- The schema to use for operations involving this entry. It may benullif no schema is available.
-
Entry
Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.attributes- The set of attributes for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.schema- The schema to use for operations involving this entry. It may benullif no schema is available.attributes- The set of attributes for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.attributes- The set of attributes for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.schema- The schema to use for operations involving this entry. It may benullif no schema is available.attributes- The set of attributes for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.attributes- The set of attributes for this entry. It must not benull.
-
Entry
public Entry(@NotNull String dn, @Nullable Schema schema, @NotNull Collection<Attribute> attributes) Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.schema- The schema to use for operations involving this entry. It may benullif no schema is available.attributes- The set of attributes for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.attributes- The set of attributes for this entry. It must not benull.
-
Entry
Creates a new entry with the provided DN and set of attributes.- Parameters:
dn- The DN for this entry. It must not benull.schema- The schema to use for operations involving this entry. It may benullif no schema is available.attributes- The set of attributes for this entry. It must not benull.
-
Entry
Creates a new entry from the provided LDIF representation.- Parameters:
entryLines- The set of lines that comprise an LDIF representation of the entry. It must not benullor empty.- Throws:
LDIFException- If the provided lines cannot be decoded as an entry in LDIF format.
-
Entry
Creates a new entry from the provided LDIF representation.- Parameters:
schema- The schema to use for operations involving this entry. It may benullif no schema is available.entryLines- The set of lines that comprise an LDIF representation of the entry. It must not benullor empty.- Throws:
LDIFException- If the provided lines cannot be decoded as an entry in LDIF format.
-
-
Method Details
-
getDN
Retrieves the DN for this entry.- Specified by:
getDNin interfaceLDIFRecord- Returns:
- The DN for this entry.
-
setDN
Specifies the DN for this entry.- Parameters:
dn- The DN for this entry. It must not benull.
-
setDN
Specifies the DN for this entry.- Parameters:
dn- The DN for this entry. It must not benull.
-
getParsedDN
Retrieves the parsed DN for this entry.- Specified by:
getParsedDNin interfaceLDIFRecord- Returns:
- The parsed DN for this entry.
- Throws:
LDAPException- If the DN string cannot be parsed as a valid DN.
-
getRDN
Retrieves the RDN for this entry.- Returns:
- The RDN for this entry, or
nullif the DN is the null DN. - Throws:
LDAPException- If the DN string cannot be parsed as a valid DN.
-
getParentDN
Retrieves the parent DN for this entry.- Returns:
- The parent DN for this entry, or
nullif there is no parent. - Throws:
LDAPException- If the DN string cannot be parsed as a valid DN.
-
getParentDNString
Retrieves the parent DN for this entry as a string.- Returns:
- The parent DN for this entry as a string, or
nullif there is no parent. - Throws:
LDAPException- If the DN string cannot be parsed as a valid DN.
-
getSchema
Retrieves the schema that will be used for this entry, if any.- Returns:
- The schema that will be used for this entry, or
nullif no schema was provided.
-
hasAttribute
Indicates whether this entry contains the specified attribute.- Parameters:
attributeName- The name of the attribute for which to make the determination. It must not benull.- Returns:
trueif this entry contains the specified attribute, orfalseif not.
-
hasAttribute
Indicates whether this entry contains the specified attribute.- Parameters:
attributeName- The name of the attribute for which to make the determination. It must not benull.schema- The schema to use to determine whether there may be alternate names for the specified attribute. It may benullif no schema is available.- Returns:
trueif this entry contains the specified attribute, orfalseif not.
-
hasAttribute
Indicates whether this entry contains the specified attribute. It will only returntrueif this entry contains an attribute with the same name and exact set of values.- Parameters:
attribute- The attribute for which to make the determination. It must not benull.- Returns:
trueif this entry contains the specified attribute, orfalseif not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull String attributeName, @NotNull String attributeValue) Indicates whether this entry contains an attribute with the given name and value.- Parameters:
attributeName- The name of the attribute for which to make the determination. It must not benull.attributeValue- The value for which to make the determination. It must not benull.- Returns:
trueif this entry contains an attribute with the specified name and value, orfalseif not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull String attributeName, @NotNull String attributeValue, @NotNull MatchingRule matchingRule) Indicates whether this entry contains an attribute with the given name and value.- Parameters:
attributeName- The name of the attribute for which to make the determination. It must not benull.attributeValue- The value for which to make the determination. It must not benull.matchingRule- The matching rule to use to make the determination. It must not benull.- Returns:
trueif this entry contains an attribute with the specified name and value, orfalseif not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull String attributeName, @NotNull byte[] attributeValue) Indicates whether this entry contains an attribute with the given name and value.- Parameters:
attributeName- The name of the attribute for which to make the determination. It must not benull.attributeValue- The value for which to make the determination. It must not benull.- Returns:
trueif this entry contains an attribute with the specified name and value, orfalseif not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull String attributeName, @NotNull byte[] attributeValue, @NotNull MatchingRule matchingRule) Indicates whether this entry contains an attribute with the given name and value.- Parameters:
attributeName- The name of the attribute for which to make the determination. It must not benull.attributeValue- The value for which to make the determination. It must not benull.matchingRule- The matching rule to use to make the determination. It must not benull.- Returns:
trueif this entry contains an attribute with the specified name and value, orfalseif not.
-
hasObjectClass
Indicates whether this entry contains the specified object class.- Parameters:
objectClassName- The name of the object class for which to make the determination. It must not benull.- Returns:
trueif this entry contains the specified object class, orfalseif not.
-
getAttributes
Retrieves the set of attributes contained in this entry.- Returns:
- The set of attributes contained in this entry.
-
getAttribute
Retrieves the attribute with the specified name.- Parameters:
attributeName- The name of the attribute to retrieve. It must not benull.- Returns:
- The requested attribute from this entry, or
nullif the specified attribute is not present in this entry.
-
getAttribute
@Nullable public final Attribute getAttribute(@NotNull String attributeName, @Nullable Schema schema) Retrieves the attribute with the specified name.- Parameters:
attributeName- The name of the attribute to retrieve. It must not benull.schema- The schema to use to determine whether there may be alternate names for the specified attribute. It may benullif no schema is available.- Returns:
- The requested attribute from this entry, or
nullif the specified attribute is not present in this entry.
-
getAttributesWithOptions
@NotNull public final List<Attribute> getAttributesWithOptions(@NotNull String baseName, @Nullable Set<String> options) Retrieves the list of attributes with the given base name and all of the specified options.- Parameters:
baseName- The base name (without any options) for the attribute to retrieve. It must not benull.options- The set of options that should be included in the attributes that are returned. It may be empty ornullif all attributes with the specified base name should be returned, regardless of the options that they contain (if any).- Returns:
- The list of attributes with the given base name and all of the specified options. It may be empty if there are no attributes with the specified base name and set of options.
-
getAttributeValue
Retrieves the value for the specified attribute, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName- The name of the attribute for which to retrieve the value. It must not benull.- Returns:
- The value for the specified attribute, or
nullif that attribute is not available.
-
getAttributeValueBytes
Retrieves the value for the specified attribute as a byte array, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName- The name of the attribute for which to retrieve the value. It must not benull.- Returns:
- The value for the specified attribute as a byte array, or
nullif that attribute is not available.
-
getAttributeValueAsBoolean
Retrieves the value for the specified attribute as a Boolean, if available. If the attribute has more than one value, then the first value will be returned. Values of "true", "t", "yes", "y", "on", and "1" will be interpreted asTRUE. Values of "false", "f", "no", "n", "off", and "0" will be interpreted asFALSE.- Parameters:
attributeName- The name of the attribute for which to retrieve the value. It must not benull.- Returns:
- The Boolean value parsed from the specified attribute, or
nullif that attribute is not available or the value cannot be parsed as a Boolean.
-
getAttributeValueAsDate
Retrieves the value for the specified attribute as a Date, formatted using the generalized time syntax, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName- The name of the attribute for which to retrieve the value. It must not benull.- Returns:
- The Date value parsed from the specified attribute, or
nullif that attribute is not available or the value cannot be parsed as a Date.
-
getAttributeValueAsDN
Retrieves the value for the specified attribute as a DN, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName- The name of the attribute for which to retrieve the value. It must not benull.- Returns:
- The DN value parsed from the specified attribute, or
nullif that attribute is not available or the value cannot be parsed as a DN.
-
getAttributeValueAsInteger
Retrieves the value for the specified attribute as an Integer, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName- The name of the attribute for which to retrieve the value. It must not benull.- Returns:
- The Integer value parsed from the specified attribute, or
nullif that attribute is not available or the value cannot be parsed as an Integer.
-
getAttributeValueAsLong
Retrieves the value for the specified attribute as a Long, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName- The name of the attribute for which to retrieve the value. It must not benull.- Returns:
- The Long value parsed from the specified attribute, or
nullif that attribute is not available or the value cannot be parsed as a Long.
-
getAttributeValues
Retrieves the set of values for the specified attribute, if available.- Parameters:
attributeName- The name of the attribute for which to retrieve the values. It must not benull.- Returns:
- The set of values for the specified attribute, or
nullif that attribute is not available.
-
getAttributeValueByteArrays
Retrieves the set of values for the specified attribute as byte arrays, if available.- Parameters:
attributeName- The name of the attribute for which to retrieve the values. It must not benull.- Returns:
- The set of values for the specified attribute as byte arrays, or
nullif that attribute is not available.
-
getObjectClassAttribute
Retrieves the "objectClass" attribute from the entry, if available.- Returns:
- The "objectClass" attribute from the entry, or
nullif that attribute not available.
-
getObjectClassValues
Retrieves the values of the "objectClass" attribute from the entry, if available.- Returns:
- The values of the "objectClass" attribute from the entry, or
nullif that attribute is not available.
-
addAttribute
Adds the provided attribute to this entry. If this entry already contains an attribute with the same name, then their values will be merged.- Parameters:
attribute- The attribute to be added. It must not benull.- Returns:
trueif the entry was updated, orfalsebecause the specified attribute already existed with all provided values.
-
addAttribute
Adds the specified attribute value to this entry, if it is not already present.- Parameters:
attributeName- The name for the attribute to be added. It must not benull.attributeValue- The value for the attribute to be added. It must not benull.- Returns:
trueif the entry was updated, orfalsebecause the specified attribute already existed with the given value.
-
addAttribute
Adds the specified attribute value to this entry, if it is not already present.- Parameters:
attributeName- The name for the attribute to be added. It must not benull.attributeValue- The value for the attribute to be added. It must not benull.- Returns:
trueif the entry was updated, orfalsebecause the specified attribute already existed with the given value.
-
addAttribute
Adds the provided attribute to this entry. If this entry already contains an attribute with the same name, then their values will be merged.- Parameters:
attributeName- The name for the attribute to be added. It must not benull.attributeValues- The value for the attribute to be added. It must not benull.- Returns:
trueif the entry was updated, orfalsebecause the specified attribute already existed with all provided values.
-
addAttribute
Adds the provided attribute to this entry. If this entry already contains an attribute with the same name, then their values will be merged.- Parameters:
attributeName- The name for the attribute to be added. It must not benull.attributeValues- The value for the attribute to be added. It must not benull.- Returns:
trueif the entry was updated, orfalsebecause the specified attribute already existed with all provided values.
-
addAttribute
public boolean addAttribute(@NotNull String attributeName, @NotNull Collection<String> attributeValues) Adds the provided attribute to this entry. If this entry already contains an attribute with the same name, then their values will be merged.- Parameters:
attributeName- The name for the attribute to be added. It must not benull.attributeValues- The value for the attribute to be added. It must not benull.- Returns:
trueif the entry was updated, orfalsebecause the specified attribute already existed with all provided values.
-
removeAttribute
Removes the specified attribute from this entry.- Parameters:
attributeName- The name of the attribute to remove. It must not benull.- Returns:
trueif the attribute was removed from the entry, orfalseif it was not present.
-
removeAttributeValue
Removes the specified attribute value from this entry if it is present. If it is the last value for the attribute, then the entire attribute will be removed. If the specified value is not present, then no change will be made.- Parameters:
attributeName- The name of the attribute from which to remove the value. It must not benull.attributeValue- The value to remove from the attribute. It must not benull.- Returns:
trueif the attribute value was removed from the entry, orfalseif it was not present.
-
removeAttributeValue
public boolean removeAttributeValue(@NotNull String attributeName, @NotNull String attributeValue, @Nullable MatchingRule matchingRule) Removes the specified attribute value from this entry if it is present. If it is the last value for the attribute, then the entire attribute will be removed. If the specified value is not present, then no change will be made.- Parameters:
attributeName- The name of the attribute from which to remove the value. It must not benull.attributeValue- The value to remove from the attribute. It must not benull.matchingRule- The matching rule to use for the attribute. It may benullto use the matching rule associated with the attribute.- Returns:
trueif the attribute value was removed from the entry, orfalseif it was not present.
-
removeAttributeValue
Removes the specified attribute value from this entry if it is present. If it is the last value for the attribute, then the entire attribute will be removed. If the specified value is not present, then no change will be made.- Parameters:
attributeName- The name of the attribute from which to remove the value. It must not benull.attributeValue- The value to remove from the attribute. It must not benull.- Returns:
trueif the attribute value was removed from the entry, orfalseif it was not present.
-
removeAttributeValue
public boolean removeAttributeValue(@NotNull String attributeName, @NotNull byte[] attributeValue, @Nullable MatchingRule matchingRule) Removes the specified attribute value from this entry if it is present. If it is the last value for the attribute, then the entire attribute will be removed. If the specified value is not present, then no change will be made.- Parameters:
attributeName- The name of the attribute from which to remove the value. It must not benull.attributeValue- The value to remove from the attribute. It must not benull.matchingRule- The matching rule to use for the attribute. It may benullto use the matching rule associated with the attribute.- Returns:
trueif the attribute value was removed from the entry, orfalseif it was not present.
-
removeAttributeValues
public boolean removeAttributeValues(@NotNull String attributeName, @NotNull String... attributeValues) Removes the specified attribute values from this entry if they are present. If the attribute does not have any remaining values, then the entire attribute will be removed. If any of the provided values are not present, then they will be ignored.- Parameters:
attributeName- The name of the attribute from which to remove the values. It must not benull.attributeValues- The set of values to remove from the attribute. It must not benull.- Returns:
trueif any attribute values were removed from the entry, orfalsenone of them were present.
-
removeAttributeValues
public boolean removeAttributeValues(@NotNull String attributeName, @NotNull byte[]... attributeValues) Removes the specified attribute values from this entry if they are present. If the attribute does not have any remaining values, then the entire attribute will be removed. If any of the provided values are not present, then they will be ignored.- Parameters:
attributeName- The name of the attribute from which to remove the values. It must not benull.attributeValues- The set of values to remove from the attribute. It must not benull.- Returns:
trueif any attribute values were removed from the entry, orfalsenone of them were present.
-
setAttribute
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.- Parameters:
attribute- The attribute to be included in this entry. It must not benull.
-
setAttribute
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.- Parameters:
attributeName- The name to use for the attribute. It must not benull.attributeValue- The value to use for the attribute. It must not benull.
-
setAttribute
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.- Parameters:
attributeName- The name to use for the attribute. It must not benull.attributeValue- The value to use for the attribute. It must not benull.
-
setAttribute
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.- Parameters:
attributeName- The name to use for the attribute. It must not benull.attributeValues- The set of values to use for the attribute. It must not benull.
-
setAttribute
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.- Parameters:
attributeName- The name to use for the attribute. It must not benull.attributeValues- The set of values to use for the attribute. It must not benull.
-
setAttribute
public void setAttribute(@NotNull String attributeName, @NotNull Collection<String> attributeValues) Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.- Parameters:
attributeName- The name to use for the attribute. It must not benull.attributeValues- The set of values to use for the attribute. It must not benull.
-
matchesBaseAndScope
public boolean matchesBaseAndScope(@NotNull String baseDN, @NotNull SearchScope scope) throws LDAPException Indicates whether this entry falls within the range of the provided search base DN and scope.- Parameters:
baseDN- The base DN for which to make the determination. It must not benull.scope- The scope for which to make the determination. It must not benull.- Returns:
trueif this entry is within the range of the provided base and scope, orfalseif not.- Throws:
LDAPException- If a problem occurs while making the determination.
-
matchesBaseAndScope
public boolean matchesBaseAndScope(@NotNull DN baseDN, @NotNull SearchScope scope) throws LDAPException Indicates whether this entry falls within the range of the provided search base DN and scope.- Parameters:
baseDN- The base DN for which to make the determination. It must not benull.scope- The scope for which to make the determination. It must not benull.- Returns:
trueif this entry is within the range of the provided base and scope, orfalseif not.- Throws:
LDAPException- If a problem occurs while making the determination.
-
diff
@NotNull public static List<Modification> diff(@NotNull Entry sourceEntry, @NotNull Entry targetEntry, boolean ignoreRDN, @Nullable String... attributes) Retrieves a set of modifications that can be applied to the source entry in order to make it match the target entry. The diff will be generated in reversible form (i.e., the same as callingdiff(sourceEntry, targetEntry, ignoreRDN, true, attributes).- Parameters:
sourceEntry- The source entry for which the set of modifications should be generated.targetEntry- The target entry, which is what the source entry should look like if the returned modifications are applied.ignoreRDN- Indicates whether to ignore differences in the RDNs of the provided entries. If this isfalse, then the resulting set of modifications may include changes to the RDN attribute. If it istrue, then differences in the entry DNs will be ignored.attributes- The set of attributes to be compared. If this isnullor empty, then all attributes will be compared. Note that if a list of attributes is specified, then matching will be performed only against the attribute base name and any differences in attribute options will be ignored.- Returns:
- A set of modifications that can be applied to the source entry in order to make it match the target entry.
-
diff
@NotNull public static List<Modification> diff(@NotNull Entry sourceEntry, @NotNull Entry targetEntry, boolean ignoreRDN, boolean reversible, @Nullable String... attributes) Retrieves a set of modifications that can be applied to the source entry in order to make it match the target entry.- Parameters:
sourceEntry- The source entry for which the set of modifications should be generated.targetEntry- The target entry, which is what the source entry should look like if the returned modifications are applied.ignoreRDN- Indicates whether to ignore differences in the RDNs of the provided entries. If this isfalse, then the resulting set of modifications may include changes to the RDN attribute. If it istrue, then differences in the entry DNs will be ignored.reversible- Indicates whether to generate the diff in reversible form. In reversible form, only the ADD or DELETE modification types will be used so that source entry could be reconstructed from the target and the resulting modifications. In non-reversible form, only the REPLACE modification type will be used. Attempts to apply the modifications obtained when using reversible form are more likely to fail if the entry has been modified since the source and target forms were obtained.attributes- The set of attributes to be compared. If this isnullor empty, then all attributes will be compared. Note that if a list of attributes is specified, then matching will be performed only against the attribute base name and any differences in attribute options will be ignored.- Returns:
- A set of modifications that can be applied to the source entry in order to make it match the target entry.
-
diff
@NotNull public static List<Modification> diff(@NotNull Entry sourceEntry, @NotNull Entry targetEntry, boolean ignoreRDN, boolean reversible, boolean byteForByte, @Nullable String... attributes) Retrieves a set of modifications that can be applied to the source entry in order to make it match the target entry.- Parameters:
sourceEntry- The source entry for which the set of modifications should be generated.targetEntry- The target entry, which is what the source entry should look like if the returned modifications are applied.ignoreRDN- Indicates whether to ignore differences in the RDNs of the provided entries. If this isfalse, then the resulting set of modifications may include changes to the RDN attribute. If it istrue, then differences in the entry DNs will be ignored.reversible- Indicates whether to generate the diff in reversible form. In reversible form, only the ADD or DELETE modification types will be used so that source entry could be reconstructed from the target and the resulting modifications. In non-reversible form, only the REPLACE modification type will be used. Attempts to apply the modifications obtained when using reversible form are more likely to fail if the entry has been modified since the source and target forms were obtained.byteForByte- Indicates whether to use a byte-for-byte comparison to identify which attribute values have changed. Using byte-for-byte comparison requires additional processing over using each attribute's associated matching rule, but it can detect changes that would otherwise be considered logically equivalent (e.g., changing the capitalization of a value that uses a case-insensitive matching rule).attributes- The set of attributes to be compared. If this isnullor empty, then all attributes will be compared. Note that if a list of attributes is specified, then matching will be performed only against the attribute base name and any differences in attribute options will be ignored.- Returns:
- A set of modifications that can be applied to the source entry in order to make it match the target entry.
-
mergeEntries
Merges the contents of all provided entries so that the resulting entry will contain all attribute values present in at least one of the entries.- Parameters:
entries- The set of entries to be merged. At least one entry must be provided.- Returns:
- An entry containing all attribute values present in at least one of the entries.
-
intersectEntries
Intersects the contents of all provided entries so that the resulting entry will contain only attribute values present in all of the provided entries.- Parameters:
entries- The set of entries to be intersected. At least one entry must be provided.- Returns:
- An entry containing only attribute values contained in all of the provided entries.
-
applyModifications
@NotNull public static Entry applyModifications(@NotNull Entry entry, boolean lenient, @NotNull Modification... modifications) throws LDAPException Creates a duplicate of the provided entry with the given set of modifications applied to it.- Parameters:
entry- The entry to be modified. It must not benull.lenient- Indicates whether to exhibit a lenient behavior for the modifications, which will cause it to ignore problems like trying to add values that already exist or to remove nonexistent attributes or values.modifications- The set of modifications to apply to the entry. It must not benullor empty.- Returns:
- An updated version of the entry with the requested modifications applied.
- Throws:
LDAPException- If a problem occurs while attempting to apply the modifications.
-
applyModifications
@NotNull public static Entry applyModifications(@NotNull Entry entry, boolean lenient, @NotNull List<Modification> modifications) throws LDAPException Creates a duplicate of the provided entry with the given set of modifications applied to it.- Parameters:
entry- The entry to be modified. It must not benull.lenient- Indicates whether to exhibit a lenient behavior for the modifications, which will cause it to ignore problems like trying to add values that already exist or to remove nonexistent attributes or values.modifications- The set of modifications to apply to the entry. It must not benullor empty.- Returns:
- An updated version of the entry with the requested modifications applied.
- Throws:
LDAPException- If a problem occurs while attempting to apply the modifications.
-
applyModifyDN
@NotNull public static Entry applyModifyDN(@NotNull Entry entry, @NotNull String newRDN, boolean deleteOldRDN) throws LDAPException Creates a duplicate of the provided entry with the appropriate changes for a modify DN operation. Any corresponding changes to the set of attribute values (to ensure that the new RDN values are present in the entry, and optionally to remove the old RDN values from the entry) will also be applied.- Parameters:
entry- The entry to be renamed. It must not benull.newRDN- The new RDN to use for the entry. It must not benull.deleteOldRDN- Indicates whether attribute values that were present in the old RDN but are no longer present in the new DN should be removed from the entry.- Returns:
- A new entry that is a duplicate of the provided entry, except with any necessary changes for the modify DN.
- Throws:
LDAPException- If a problem is encountered during modify DN processing.
-
applyModifyDN
@NotNull public static Entry applyModifyDN(@NotNull Entry entry, @NotNull String newRDN, boolean deleteOldRDN, @Nullable String newSuperiorDN) throws LDAPException Creates a duplicate of the provided entry with the appropriate changes for a modify DN operation. Any corresponding changes to the set of attribute values (to ensure that the new RDN values are present in the entry, and optionally to remove the old RDN values from the entry) will also be applied.- Parameters:
entry- The entry to be renamed. It must not benull.newRDN- The new RDN to use for the entry. It must not benull.deleteOldRDN- Indicates whether attribute values that were present in the old RDN but are no longer present in the new DN should be removed from the entry.newSuperiorDN- The new superior DN for the entry. If this isnull, then the entry will remain below its existing parent. If it is non-null, then the resulting DN will be a concatenation of the new RDN and the new superior DN.- Returns:
- A new entry that is a duplicate of the provided entry, except with any necessary changes for the modify DN.
- Throws:
LDAPException- If a problem is encountered during modify DN processing.
-
hashCode
Generates a hash code for this entry. -
equals
Indicates whether the provided object is equal to this entry. The provided object will only be considered equal to this entry if it is an entry with the same DN and set of attributes. -
duplicate
Creates a new entry that is a duplicate of this entry.- Returns:
- A new entry that is a duplicate of this entry.
-
toLDIF
Retrieves an LDIF representation of this entry, with each attribute value on a separate line. Long lines will not be wrapped.- Specified by:
toLDIFin interfaceLDIFRecord- Returns:
- An LDIF representation of this entry.
-
toLDIF
Retrieves an LDIF representation of this entry, with each attribute value on a separate line. Long lines will be wrapped at the specified column.- Specified by:
toLDIFin interfaceLDIFRecord- Parameters:
wrapColumn- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.- Returns:
- An LDIF representation of this entry.
-
toLDIF
Appends an LDIF representation of this entry to the provided buffer. Long lines will not be wrapped.- Specified by:
toLDIFin interfaceLDIFRecord- Parameters:
buffer- The buffer to which the LDIF representation of this entry should be written.
-
toLDIF
Appends an LDIF representation of this entry to the provided buffer.- Specified by:
toLDIFin interfaceLDIFRecord- Parameters:
buffer- The buffer to which the LDIF representation of this entry should be written.wrapColumn- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.
-
toLDIFString
Retrieves an LDIF-formatted string representation of this entry. No wrapping will be performed, and no extra blank lines will be added.- Specified by:
toLDIFStringin interfaceLDIFRecord- Returns:
- An LDIF-formatted string representation of this entry.
-
toLDIFString
Retrieves an LDIF-formatted string representation of this entry. No extra blank lines will be added.- Specified by:
toLDIFStringin interfaceLDIFRecord- Parameters:
wrapColumn- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.- Returns:
- An LDIF-formatted string representation of this entry.
-
toLDIFString
Appends an LDIF-formatted string representation of this entry to the provided buffer. No wrapping will be performed, and no extra blank lines will be added.- Specified by:
toLDIFStringin interfaceLDIFRecord- Parameters:
buffer- The buffer to which to append the LDIF representation of this entry.
-
toLDIFString
Appends an LDIF-formatted string representation of this entry to the provided buffer. No extra blank lines will be added.- Specified by:
toLDIFStringin interfaceLDIFRecord- Parameters:
buffer- The buffer to which to append the LDIF representation of this entry.wrapColumn- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.
-
toString
Retrieves a string representation of this entry.- Specified by:
toStringin interfaceLDIFRecord- Overrides:
toStringin classObject- Returns:
- A string representation of this entry.
-
toString
Appends a string representation of this entry to the provided buffer.- Specified by:
toStringin interfaceLDIFRecord- Parameters:
buffer- The buffer to which to append the string representation of this entry.
-