Package com.unboundid.ldap.sdk
Class Entry
- java.lang.Object
-
- com.unboundid.ldap.sdk.Entry
-
- All Implemented Interfaces:
LDIFRecord
,java.io.Serializable
- Direct Known Subclasses:
ReadOnlyEntry
@Mutable @NotExtensible @ThreadSafety(level=NOT_THREADSAFE) public class Entry extends java.lang.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:
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.
Thediff(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 ofModification
objects that can be used to modify one entry so that it contains the same set of data as another. TheapplyModifications(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:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description Entry(DN dn)
Creates a new entry with the provided DN and no attributes.Entry(DN dn, Attribute... attributes)
Creates a new entry with the provided DN and set of attributes.Entry(DN dn, Schema schema)
Creates a new entry with the provided DN and no attributes.Entry(DN dn, Schema schema, Attribute... attributes)
Creates a new entry with the provided DN and set of attributes.Entry(DN dn, Schema schema, java.util.Collection<Attribute> attributes)
Creates a new entry with the provided DN and set of attributes.Entry(DN dn, java.util.Collection<Attribute> attributes)
Creates a new entry with the provided DN and set of attributes.protected
Entry(Entry e)
Creates a new entry that wraps the provided entry.Entry(Schema schema, java.lang.String... entryLines)
Creates a new entry from the provided LDIF representation.Entry(java.lang.String dn)
Creates a new entry with the provided DN and no attributes.Entry(java.lang.String... entryLines)
Creates a new entry from the provided LDIF representation.Entry(java.lang.String dn, Attribute... attributes)
Creates a new entry with the provided DN and set of attributes.Entry(java.lang.String dn, Schema schema)
Creates a new entry with the provided DN and no attributes.Entry(java.lang.String dn, Schema schema, Attribute... attributes)
Creates a new entry with the provided DN and set of attributes.Entry(java.lang.String dn, Schema schema, java.util.Collection<Attribute> attributes)
Creates a new entry with the provided DN and set of attributes.Entry(java.lang.String dn, java.util.Collection<Attribute> attributes)
Creates a new entry with the provided DN and set of attributes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addAttribute(Attribute attribute)
Adds the provided attribute to this entry.boolean
addAttribute(java.lang.String attributeName, byte[] attributeValue)
Adds the specified attribute value to this entry, if it is not already present.boolean
addAttribute(java.lang.String attributeName, byte[]... attributeValues)
Adds the provided attribute to this entry.boolean
addAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Adds the specified attribute value to this entry, if it is not already present.boolean
addAttribute(java.lang.String attributeName, java.lang.String... attributeValues)
Adds the provided attribute to this entry.boolean
addAttribute(java.lang.String attributeName, java.util.Collection<java.lang.String> attributeValues)
Adds the provided attribute to this entry.static Entry
applyModifications(Entry entry, boolean lenient, Modification... modifications)
Creates a duplicate of the provided entry with the given set of modifications applied to it.static Entry
applyModifications(Entry entry, boolean lenient, java.util.List<Modification> modifications)
Creates a duplicate of the provided entry with the given set of modifications applied to it.static Entry
applyModifyDN(Entry entry, java.lang.String newRDN, boolean deleteOldRDN)
Creates a duplicate of the provided entry with the appropriate changes for a modify DN operation.static Entry
applyModifyDN(Entry entry, java.lang.String newRDN, boolean deleteOldRDN, java.lang.String newSuperiorDN)
Creates a duplicate of the provided entry with the appropriate changes for a modify DN operation.static java.util.List<Modification>
diff(Entry sourceEntry, Entry targetEntry, boolean ignoreRDN, boolean reversible, boolean byteForByte, java.lang.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 java.util.List<Modification>
diff(Entry sourceEntry, Entry targetEntry, boolean ignoreRDN, boolean reversible, java.lang.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 java.util.List<Modification>
diff(Entry sourceEntry, Entry targetEntry, boolean ignoreRDN, java.lang.String... attributes)
Retrieves a set of modifications that can be applied to the source entry in order to make it match the target entry.Entry
duplicate()
Creates a new entry that is a duplicate of this entry.boolean
equals(java.lang.Object o)
Indicates whether the provided object is equal to this entry.Attribute
getAttribute(java.lang.String attributeName)
Retrieves the attribute with the specified name.Attribute
getAttribute(java.lang.String attributeName, Schema schema)
Retrieves the attribute with the specified name.java.util.Collection<Attribute>
getAttributes()
Retrieves the set of attributes contained in this entry.java.util.List<Attribute>
getAttributesWithOptions(java.lang.String baseName, java.util.Set<java.lang.String> options)
Retrieves the list of attributes with the given base name and all of the specified options.java.lang.String
getAttributeValue(java.lang.String attributeName)
Retrieves the value for the specified attribute, if available.java.lang.Boolean
getAttributeValueAsBoolean(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Boolean, if available.java.util.Date
getAttributeValueAsDate(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Date, formatted using the generalized time syntax, if available.DN
getAttributeValueAsDN(java.lang.String attributeName)
Retrieves the value for the specified attribute as a DN, if available.java.lang.Integer
getAttributeValueAsInteger(java.lang.String attributeName)
Retrieves the value for the specified attribute as an Integer, if available.java.lang.Long
getAttributeValueAsLong(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Long, if available.byte[][]
getAttributeValueByteArrays(java.lang.String attributeName)
Retrieves the set of values for the specified attribute as byte arrays, if available.byte[]
getAttributeValueBytes(java.lang.String attributeName)
Retrieves the value for the specified attribute as a byte array, if available.java.lang.String[]
getAttributeValues(java.lang.String attributeName)
Retrieves the set of values for the specified attribute, if available.java.lang.String
getDN()
Retrieves the DN for this entry.Attribute
getObjectClassAttribute()
Retrieves the "objectClass" attribute from the entry, if available.java.lang.String[]
getObjectClassValues()
Retrieves the values of the "objectClass" attribute from the entry, if available.DN
getParentDN()
Retrieves the parent DN for this entry.java.lang.String
getParentDNString()
Retrieves the parent DN for this entry as a string.DN
getParsedDN()
Retrieves the parsed DN for this entry.RDN
getRDN()
Retrieves the RDN for this entry.protected Schema
getSchema()
Retrieves the schema that will be used for this entry, if any.boolean
hasAttribute(Attribute attribute)
Indicates whether this entry contains the specified attribute.boolean
hasAttribute(java.lang.String attributeName)
Indicates whether this entry contains the specified attribute.boolean
hasAttribute(java.lang.String attributeName, Schema schema)
Indicates whether this entry contains the specified attribute.boolean
hasAttributeValue(java.lang.String attributeName, byte[] attributeValue)
Indicates whether this entry contains an attribute with the given name and value.boolean
hasAttributeValue(java.lang.String attributeName, byte[] attributeValue, MatchingRule matchingRule)
Indicates whether this entry contains an attribute with the given name and value.boolean
hasAttributeValue(java.lang.String attributeName, java.lang.String attributeValue)
Indicates whether this entry contains an attribute with the given name and value.boolean
hasAttributeValue(java.lang.String attributeName, java.lang.String attributeValue, MatchingRule matchingRule)
Indicates whether this entry contains an attribute with the given name and value.int
hashCode()
Generates a hash code for this entry.boolean
hasObjectClass(java.lang.String objectClassName)
Indicates whether this entry contains the specified object class.static Entry
intersectEntries(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.boolean
matchesBaseAndScope(DN baseDN, SearchScope scope)
Indicates whether this entry falls within the range of the provided search base DN and scope.boolean
matchesBaseAndScope(java.lang.String baseDN, SearchScope scope)
Indicates whether this entry falls within the range of the provided search base DN and scope.static Entry
mergeEntries(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.boolean
removeAttribute(java.lang.String attributeName)
Removes the specified attribute from this entry.boolean
removeAttributeValue(java.lang.String attributeName, byte[] attributeValue)
Removes the specified attribute value from this entry if it is present.boolean
removeAttributeValue(java.lang.String attributeName, byte[] attributeValue, MatchingRule matchingRule)
Removes the specified attribute value from this entry if it is present.boolean
removeAttributeValue(java.lang.String attributeName, java.lang.String attributeValue)
Removes the specified attribute value from this entry if it is present.boolean
removeAttributeValue(java.lang.String attributeName, java.lang.String attributeValue, MatchingRule matchingRule)
Removes the specified attribute value from this entry if it is present.boolean
removeAttributeValues(java.lang.String attributeName, byte[]... attributeValues)
Removes the specified attribute values from this entry if they are present.boolean
removeAttributeValues(java.lang.String attributeName, java.lang.String... attributeValues)
Removes the specified attribute values from this entry if they are present.void
setAttribute(Attribute attribute)
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.void
setAttribute(java.lang.String attributeName, byte[] attributeValue)
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.void
setAttribute(java.lang.String attributeName, byte[]... attributeValues)
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.void
setAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.void
setAttribute(java.lang.String attributeName, java.lang.String... attributeValues)
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.void
setAttribute(java.lang.String attributeName, java.util.Collection<java.lang.String> attributeValues)
Adds the provided attribute to this entry, replacing any existing set of values for the associated attribute.void
setDN(DN dn)
Specifies the DN for this entry.void
setDN(java.lang.String dn)
Specifies the DN for this entry.java.lang.String[]
toLDIF()
Retrieves an LDIF representation of this entry, with each attribute value on a separate line.java.lang.String[]
toLDIF(int wrapColumn)
Retrieves an LDIF representation of this entry, with each attribute value on a separate line.void
toLDIF(ByteStringBuffer buffer)
Appends an LDIF representation of this entry to the provided buffer.void
toLDIF(ByteStringBuffer buffer, int wrapColumn)
Appends an LDIF representation of this entry to the provided buffer.java.lang.String
toLDIFString()
Retrieves an LDIF-formatted string representation of this entry.java.lang.String
toLDIFString(int wrapColumn)
Retrieves an LDIF-formatted string representation of this entry.void
toLDIFString(java.lang.StringBuilder buffer)
Appends an LDIF-formatted string representation of this entry to the provided buffer.void
toLDIFString(java.lang.StringBuilder buffer, int wrapColumn)
Appends an LDIF-formatted string representation of this entry to the provided buffer.java.lang.String
toString()
Retrieves a string representation of this entry.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this entry to the provided buffer.
-
-
-
Constructor Detail
-
Entry
protected Entry(@NotNull Entry e)
Creates a new entry that wraps the provided entry.- Parameters:
e
- The entry to be wrapped.
-
Entry
public Entry(@NotNull java.lang.String dn)
Creates a new entry with the provided DN and no attributes.- Parameters:
dn
- The DN for this entry. It must not benull
.
-
Entry
public Entry(@NotNull java.lang.String dn, @Nullable Schema schema)
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 benull
if no schema is available.
-
Entry
public Entry(@NotNull DN dn)
Creates a new entry with the provided DN and no attributes.- Parameters:
dn
- The DN for this entry. It must not benull
.
-
Entry
public Entry(@NotNull DN dn, @Nullable Schema schema)
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 benull
if no schema is available.
-
Entry
public Entry(@NotNull java.lang.String dn, @NotNull 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
.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull java.lang.String dn, @Nullable Schema schema, @NotNull 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 benull
if no schema is available.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull DN dn, @NotNull 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
.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull DN dn, @Nullable Schema schema, @NotNull 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 benull
if no schema is available.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull java.lang.String dn, @NotNull java.util.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
.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull java.lang.String dn, @Nullable Schema schema, @NotNull java.util.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 benull
if no schema is available.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull DN dn, @NotNull java.util.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
.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull DN dn, @Nullable Schema schema, @NotNull java.util.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 benull
if no schema is available.attributes
- The set of attributes for this entry. It must not benull
.
-
Entry
public Entry(@NotNull java.lang.String... entryLines) throws LDIFException
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 benull
or empty.- Throws:
LDIFException
- If the provided lines cannot be decoded as an entry in LDIF format.
-
Entry
public Entry(@Nullable Schema schema, @NotNull java.lang.String... entryLines) throws LDIFException
Creates a new entry from the provided LDIF representation.- Parameters:
schema
- The schema to use for operations involving this entry. It may benull
if no schema is available.entryLines
- The set of lines that comprise an LDIF representation of the entry. It must not benull
or empty.- Throws:
LDIFException
- If the provided lines cannot be decoded as an entry in LDIF format.
-
-
Method Detail
-
getDN
@NotNull public final java.lang.String getDN()
Retrieves the DN for this entry.- Specified by:
getDN
in interfaceLDIFRecord
- Returns:
- The DN for this entry.
-
setDN
public void setDN(@NotNull java.lang.String dn)
Specifies the DN for this entry.- Parameters:
dn
- The DN for this entry. It must not benull
.
-
setDN
public void setDN(@NotNull DN dn)
Specifies the DN for this entry.- Parameters:
dn
- The DN for this entry. It must not benull
.
-
getParsedDN
@NotNull public final DN getParsedDN() throws LDAPException
Retrieves the parsed DN for this entry.- Specified by:
getParsedDN
in interfaceLDIFRecord
- Returns:
- The parsed DN for this entry.
- Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
getRDN
@Nullable public final RDN getRDN() throws LDAPException
Retrieves the RDN for this entry.- Returns:
- The RDN for this entry, or
null
if the DN is the null DN. - Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
getParentDN
@Nullable public final DN getParentDN() throws LDAPException
Retrieves the parent DN for this entry.- Returns:
- The parent DN for this entry, or
null
if there is no parent. - Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
getParentDNString
@NotNull public final java.lang.String getParentDNString() throws LDAPException
Retrieves the parent DN for this entry as a string.- Returns:
- The parent DN for this entry as a string, or
null
if there is no parent. - Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
getSchema
@Nullable protected Schema getSchema()
Retrieves the schema that will be used for this entry, if any.- Returns:
- The schema that will be used for this entry, or
null
if no schema was provided.
-
hasAttribute
public final boolean hasAttribute(@NotNull java.lang.String attributeName)
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:
true
if this entry contains the specified attribute, orfalse
if not.
-
hasAttribute
public final boolean hasAttribute(@NotNull java.lang.String attributeName, @Nullable Schema schema)
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 benull
if no schema is available.- Returns:
true
if this entry contains the specified attribute, orfalse
if not.
-
hasAttribute
public final boolean hasAttribute(@NotNull Attribute attribute)
Indicates whether this entry contains the specified attribute. It will only returntrue
if 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:
true
if this entry contains the specified attribute, orfalse
if not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull java.lang.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:
true
if this entry contains an attribute with the specified name and value, orfalse
if not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull java.lang.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:
true
if this entry contains an attribute with the specified name and value, orfalse
if not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull java.lang.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:
true
if this entry contains an attribute with the specified name and value, orfalse
if not.
-
hasAttributeValue
public final boolean hasAttributeValue(@NotNull java.lang.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:
true
if this entry contains an attribute with the specified name and value, orfalse
if not.
-
hasObjectClass
public final boolean hasObjectClass(@NotNull java.lang.String objectClassName)
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:
true
if this entry contains the specified object class, orfalse
if not.
-
getAttributes
@NotNull public final java.util.Collection<Attribute> getAttributes()
Retrieves the set of attributes contained in this entry.- Returns:
- The set of attributes contained in this entry.
-
getAttribute
@Nullable public final Attribute getAttribute(@NotNull java.lang.String attributeName)
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
null
if the specified attribute is not present in this entry.
-
getAttribute
@Nullable public final Attribute getAttribute(@NotNull java.lang.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 benull
if no schema is available.- Returns:
- The requested attribute from this entry, or
null
if the specified attribute is not present in this entry.
-
getAttributesWithOptions
@NotNull public final java.util.List<Attribute> getAttributesWithOptions(@NotNull java.lang.String baseName, @Nullable java.util.Set<java.lang.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 ornull
if 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
@Nullable public java.lang.String getAttributeValue(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available.
-
getAttributeValueBytes
@Nullable public byte[] getAttributeValueBytes(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available.
-
getAttributeValueAsBoolean
@Nullable public java.lang.Boolean getAttributeValueAsBoolean(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available or the value cannot be parsed as a Boolean.
-
getAttributeValueAsDate
@Nullable public java.util.Date getAttributeValueAsDate(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available or the value cannot be parsed as a Date.
-
getAttributeValueAsDN
@Nullable public DN getAttributeValueAsDN(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available or the value cannot be parsed as a DN.
-
getAttributeValueAsInteger
@Nullable public java.lang.Integer getAttributeValueAsInteger(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available or the value cannot be parsed as an Integer.
-
getAttributeValueAsLong
@Nullable public java.lang.Long getAttributeValueAsLong(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available or the value cannot be parsed as a Long.
-
getAttributeValues
@Nullable public java.lang.String[] getAttributeValues(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available.
-
getAttributeValueByteArrays
@Nullable public byte[][] getAttributeValueByteArrays(@NotNull java.lang.String attributeName)
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
null
if that attribute is not available.
-
getObjectClassAttribute
@Nullable public final Attribute getObjectClassAttribute()
Retrieves the "objectClass" attribute from the entry, if available.- Returns:
- The "objectClass" attribute from the entry, or
null
if that attribute not available.
-
getObjectClassValues
@Nullable public final java.lang.String[] getObjectClassValues()
Retrieves the values of the "objectClass" attribute from the entry, if available.- Returns:
- The values of the "objectClass" attribute from the entry, or
null
if that attribute is not available.
-
addAttribute
public boolean addAttribute(@NotNull Attribute attribute)
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:
true
if the entry was updated, orfalse
because the specified attribute already existed with all provided values.
-
addAttribute
public boolean addAttribute(@NotNull java.lang.String attributeName, @NotNull java.lang.String attributeValue)
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:
true
if the entry was updated, orfalse
because the specified attribute already existed with the given value.
-
addAttribute
public boolean addAttribute(@NotNull java.lang.String attributeName, @NotNull byte[] attributeValue)
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:
true
if the entry was updated, orfalse
because the specified attribute already existed with the given value.
-
addAttribute
public boolean addAttribute(@NotNull java.lang.String attributeName, @NotNull java.lang.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:
true
if the entry was updated, orfalse
because the specified attribute already existed with all provided values.
-
addAttribute
public boolean addAttribute(@NotNull java.lang.String attributeName, @NotNull byte[]... 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:
true
if the entry was updated, orfalse
because the specified attribute already existed with all provided values.
-
addAttribute
public boolean addAttribute(@NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.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:
true
if the entry was updated, orfalse
because the specified attribute already existed with all provided values.
-
removeAttribute
public boolean removeAttribute(@NotNull java.lang.String attributeName)
Removes the specified attribute from this entry.- Parameters:
attributeName
- The name of the attribute to remove. It must not benull
.- Returns:
true
if the attribute was removed from the entry, orfalse
if it was not present.
-
removeAttributeValue
public boolean removeAttributeValue(@NotNull java.lang.String attributeName, @NotNull java.lang.String attributeValue)
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:
true
if the attribute value was removed from the entry, orfalse
if it was not present.
-
removeAttributeValue
public boolean removeAttributeValue(@NotNull java.lang.String attributeName, @NotNull java.lang.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 benull
to use the matching rule associated with the attribute.- Returns:
true
if the attribute value was removed from the entry, orfalse
if it was not present.
-
removeAttributeValue
public boolean removeAttributeValue(@NotNull java.lang.String attributeName, @NotNull byte[] attributeValue)
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:
true
if the attribute value was removed from the entry, orfalse
if it was not present.
-
removeAttributeValue
public boolean removeAttributeValue(@NotNull java.lang.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 benull
to use the matching rule associated with the attribute.- Returns:
true
if the attribute value was removed from the entry, orfalse
if it was not present.
-
removeAttributeValues
public boolean removeAttributeValues(@NotNull java.lang.String attributeName, @NotNull java.lang.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:
true
if any attribute values were removed from the entry, orfalse
none of them were present.
-
removeAttributeValues
public boolean removeAttributeValues(@NotNull java.lang.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:
true
if any attribute values were removed from the entry, orfalse
none of them were present.
-
setAttribute
public void setAttribute(@NotNull Attribute attribute)
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
public void setAttribute(@NotNull java.lang.String attributeName, @NotNull java.lang.String attributeValue)
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
public void setAttribute(@NotNull java.lang.String attributeName, @NotNull byte[] attributeValue)
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
public void setAttribute(@NotNull java.lang.String attributeName, @NotNull java.lang.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
.
-
setAttribute
public void setAttribute(@NotNull java.lang.String attributeName, @NotNull byte[]... 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
.
-
setAttribute
public void setAttribute(@NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.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 java.lang.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:
true
if this entry is within the range of the provided base and scope, orfalse
if 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:
true
if this entry is within the range of the provided base and scope, orfalse
if not.- Throws:
LDAPException
- If a problem occurs while making the determination.
-
diff
@NotNull public static java.util.List<Modification> diff(@NotNull Entry sourceEntry, @NotNull Entry targetEntry, boolean ignoreRDN, @Nullable java.lang.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 isnull
or 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 java.util.List<Modification> diff(@NotNull Entry sourceEntry, @NotNull Entry targetEntry, boolean ignoreRDN, boolean reversible, @Nullable java.lang.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 isnull
or 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 java.util.List<Modification> diff(@NotNull Entry sourceEntry, @NotNull Entry targetEntry, boolean ignoreRDN, boolean reversible, boolean byteForByte, @Nullable java.lang.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 isnull
or 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
@NotNull public static Entry mergeEntries(@NotNull 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.- 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
@NotNull public static Entry intersectEntries(@NotNull 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.- 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 benull
or 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 java.util.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 benull
or 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 java.lang.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 java.lang.String newRDN, boolean deleteOldRDN, @Nullable java.lang.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
public int hashCode()
Generates a hash code for this entry.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The generated hash code for this entry.
-
equals
public boolean equals(@Nullable java.lang.Object o)
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.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- The object for which to make the determination.- Returns:
true
if the provided object is considered equal to this entry, orfalse
if not.
-
duplicate
@NotNull public Entry duplicate()
Creates a new entry that is a duplicate of this entry.- Returns:
- A new entry that is a duplicate of this entry.
-
toLDIF
@NotNull public final java.lang.String[] toLDIF()
Retrieves an LDIF representation of this entry, with each attribute value on a separate line. Long lines will not be wrapped.- Specified by:
toLDIF
in interfaceLDIFRecord
- Returns:
- An LDIF representation of this entry.
-
toLDIF
@NotNull public final java.lang.String[] toLDIF(int wrapColumn)
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:
toLDIF
in 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
public final void toLDIF(@NotNull ByteStringBuffer buffer)
Appends an LDIF representation of this entry to the provided buffer. Long lines will not be wrapped.- Specified by:
toLDIF
in interfaceLDIFRecord
- Parameters:
buffer
- The buffer to which the LDIF representation of this entry should be written.
-
toLDIF
public final void toLDIF(@NotNull ByteStringBuffer buffer, int wrapColumn)
Appends an LDIF representation of this entry to the provided buffer.- Specified by:
toLDIF
in 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
@NotNull public final java.lang.String 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:
toLDIFString
in interfaceLDIFRecord
- Returns:
- An LDIF-formatted string representation of this entry.
-
toLDIFString
@NotNull public final java.lang.String toLDIFString(int wrapColumn)
Retrieves an LDIF-formatted string representation of this entry. No extra blank lines will be added.- Specified by:
toLDIFString
in 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
public final void toLDIFString(@NotNull java.lang.StringBuilder buffer)
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:
toLDIFString
in interfaceLDIFRecord
- Parameters:
buffer
- The buffer to which to append the LDIF representation of this entry.
-
toLDIFString
public final void toLDIFString(@NotNull java.lang.StringBuilder buffer, int wrapColumn)
Appends an LDIF-formatted string representation of this entry to the provided buffer. No extra blank lines will be added.- Specified by:
toLDIFString
in 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
@NotNull public final java.lang.String toString()
Retrieves a string representation of this entry.- Specified by:
toString
in interfaceLDIFRecord
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this entry.
-
toString
public void toString(@NotNull java.lang.StringBuilder buffer)
Appends a string representation of this entry to the provided buffer.- Specified by:
toString
in interfaceLDIFRecord
- Parameters:
buffer
- The buffer to which to append the string representation of this entry.
-
-