Interface Entry
-
- All Known Subinterfaces:
AddRequest,SearchResultEntry
- All Known Implementing Classes:
AbstractEntry,AbstractMapEntry,Entries.NullEntry,LinkedHashMapEntry,TreeMapEntry
public interface EntryAn entry, comprising of a distinguished name and zero or more attributes.Some methods require a schema in order to decode their parameters (e.g.
addAttribute(String, Object...)andsetName(String)). In these cases the default schema is used unless an alternative schema is specified in theEntryconstructor. The default schema is not used for any other purpose. In particular, anEntrymay contain attributes which have been decoded using different schemas.When determining whether an entry already contains a particular attribute, attribute descriptions will be compared using
AttributeDescription.matches(org.forgerock.opendj.ldap.AttributeDescription).Full LDAP modify semantics are provided via the
addAttribute(org.forgerock.opendj.ldap.Attribute),removeAttribute(org.forgerock.opendj.ldap.Attribute, java.util.Collection<? super org.forgerock.opendj.ldap.ByteString>), andreplaceAttribute(org.forgerock.opendj.ldap.Attribute)methods.Implementations should specify any constraints or special behavior. Specifically:
- Which methods are supported.
- The order in which attributes are returned using the
getAllAttributes()method. - How existing attributes are modified during calls to
addAttribute(org.forgerock.opendj.ldap.Attribute),removeAttribute(org.forgerock.opendj.ldap.Attribute, java.util.Collection<? super org.forgerock.opendj.ldap.ByteString>), andreplaceAttribute(org.forgerock.opendj.ldap.Attribute)and the conditions, if any, where a reference to the passed in attribute is maintained.
- See Also:
Entries
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default EntryaddAttribute(String attributeDescription, Object... values)Ensures that this entry contains the provided attribute and values (optional operation).default booleanaddAttribute(Attribute attribute)Ensures that this entry contains the provided attribute and values (optional operation).default booleanaddAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues)Ensures that this entry contains the provided attribute and values (optional operation).default AttributeaddAttributeIfAbsent(Attribute attribute)Adds the provided attribute if it is not already present in this Entry and returnsnull.default EntryclearAttributes()Removes all the attributes from this entry (optional operation).default booleancontainsAnyAttributes(String attributeDescription)Returnstrueif this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.default booleancontainsAnyAttributes(AttributeDescription attributeDescription)Returnstrueif this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.default booleancontainsAttribute(String attributeDescription, Object... values)Returnstrueif this entry contains all of the attribute values contained invalues.default booleancontainsAttribute(AttributeDescription attributeDescription, Object... values)Returnstrueif this entry contains all of the attribute values contained invalues.default booleancontainsAttribute(Attribute attribute, Collection<? super ByteString> missingValues)Returnstrueif this entry contains all of the attribute values contained inattribute.booleanequals(Object object)Returnstrueifobjectis an entry which is equal to this entry.Iterable<Attribute>getAllAttributes()Returns anIterablecontaining all of the attributes in this entry.default Iterable<Attribute>getAllAttributes(String attributeDescription)Returns anIterablecontaining all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description.default Iterable<Attribute>getAllAttributes(AttributeDescription attributeDescription)Returns anIterablecontaining all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description.default AttributegetAttribute(String attributeDescription)Returns the named attribute contained in this entry, ornullif it is not included with this entry.default AttributegetAttribute(AttributeDescription attributeDescription)Returns the named attribute contained in this entry, ornullif it is not included with this entry.intgetAttributeCount()Returns the number of attributes in this entry.DngetName()Returns the distinguished name of this entry.inthashCode()Returns the hash code for this entry.default AttributemergeAttribute(Attribute attribute, BiFunction<? super Attribute,? super Attribute,? extends Attribute> mergeFunction)Adds the provided attribute if it is not already present in this Entry.default AttributeParserparseAttribute(String attributeDescription)Returns a parser for the named attribute contained in this entry.default AttributeParserparseAttribute(AttributeDescription attributeDescription)Returns a parser for the named attribute contained in this entry.default EntryremoveAttribute(String attributeDescription, Object... values)Removes all of the attribute values contained invaluesfrom the named attribute in this entry if it is present (optional operation).default booleanremoveAttribute(AttributeDescription attributeDescription)Removes the named attribute from this entry if it is present (optional operation).default booleanremoveAttribute(Attribute attribute, Collection<? super ByteString> missingValues)Removes all of the attribute values contained inattributefrom this entry if it is present (optional operation).default EntryreplaceAttribute(String attributeDescription, Object... values)Adds all of the attribute values contained invaluesto this entry, replacing any existing attribute values (optional operation).default booleanreplaceAttribute(Attribute attribute)Adds all of the attribute values contained inattributeto this entry, replacing any existing attribute values (optional operation).default EntrysetName(String dn)Sets the distinguished name of this entry (optional operation).default EntrysetName(Dn dn)Sets the distinguished name of this entry (optional operation).StringtoString()Returns a string representation of this entry.
-
-
-
Method Detail
-
addAttribute
default boolean addAttribute(Attribute attribute)
Ensures that this entry contains the provided attribute and values (optional operation). This method has the following semantics:- If this entry does not already contain an attribute with a
matchingattribute description, then this entry will be modified such that it containsattribute, even if it is empty. - If this entry already contains an attribute with a
matchingattribute description, then the attribute values contained inattributewill be merged with the existing attribute values.
NOTE: When
attributeis non-empty, this method implements LDAP Modify add semantics.- Parameters:
attribute- The attribute values to be added to this entry, merging with any existing attribute values.- Returns:
trueif this entry changed as a result of this call.- Throws:
UnsupportedOperationException- If this entry does not permit attributes or their values to be added.NullPointerException- Ifattributewasnull.
- If this entry does not already contain an attribute with a
-
addAttribute
default boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues)
Ensures that this entry contains the provided attribute and values (optional operation). This method has the following semantics:- If this entry does not already contain an attribute with a
matchingattribute description, then this entry will be modified such that it containsattribute, even if it is empty. - If this entry already contains an attribute with a
matchingattribute description, then the attribute values contained inattributewill be merged with the existing attribute values.
NOTE: When
attributeis non-empty, this method implements LDAP Modify add semantics.- Parameters:
attribute- The attribute values to be added to this entry, merging with any existing attribute values.duplicateValues- A collection into which duplicate values will be added, ornullif duplicate values should not be saved.- Returns:
trueif this entry changed as a result of this call.- Throws:
UnsupportedOperationException- If this entry does not permit attributes or their values to be added.NullPointerException- Ifattributewasnull.
- If this entry does not already contain an attribute with a
-
addAttribute
default Entry addAttribute(String attributeDescription, Object... values)
Ensures that this entry contains the provided attribute and values (optional operation). This method has the following semantics:- If this entry does not already contain an attribute with a
matchingattribute description, then this entry will be modified such that it containsattribute, even if it is empty. - If this entry already contains an attribute with a
matchingattribute description, then the attribute values contained inattributewill be merged with the existing attribute values.
The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.NOTE: When
attributeis non-empty, this method implements LDAP Modify add semantics.- Parameters:
attributeDescription- The name of the attribute whose values are to be added.values- The attribute values to be added to this entry, merging any existing attribute values.- Returns:
- This entry.
- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.UnsupportedOperationException- If this entry does not permit attributes or their values to be added.NullPointerException- IfattributeDescriptionwasnull.
- If this entry does not already contain an attribute with a
-
addAttributeIfAbsent
default Attribute addAttributeIfAbsent(Attribute attribute)
Adds the provided attribute if it is not already present in this Entry and returnsnull. Otherwise returns the existing attribute.NOTE: this method is equivalent to
Map.putIfAbsent(Object, Object).- Parameters:
attribute- The non-nullattribute to be added if it is not already present.- Returns:
nullif the attribute was added, or the existing attribute (in which case the entry is unchanged).- Throws:
UnsupportedOperationException- If this entry does not permit attributes or their values to be added.NullPointerException- Ifattributewasnull.
-
clearAttributes
default Entry clearAttributes()
Removes all the attributes from this entry (optional operation).- Returns:
- This entry.
- Throws:
UnsupportedOperationException- If this entry does not permit attributes to be removed.
-
containsAttribute
default boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues)
Returnstrueif this entry contains all of the attribute values contained inattribute. Ifattributeis empty then this method will returntrueif the attribute is present in this entry, regardless of how many values it contains.- Parameters:
attribute- The attribute values whose presence in this entry is to be tested.missingValues- A collection into which missing values will be added, ornullif missing values should not be saved.- Returns:
trueif this entry contains all of the attribute values contained inattribute.- Throws:
NullPointerException- Ifattributewasnull.
-
containsAttribute
default boolean containsAttribute(String attributeDescription, Object... values)
Returnstrueif this entry contains all of the attribute values contained invalues. Ifvaluesisnullor empty then this method will returntrueif the attribute is present in this entry, regardless of how many values it contains.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The name of the attribute whose presence in this entry is to be tested.values- The attribute values whose presence in this entry is to be tested, which may benull.- Returns:
trueif this entry contains all of the attribute values contained invalues.- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.NullPointerException- IfattributeDescriptionwasnull.
-
containsAttribute
default boolean containsAttribute(AttributeDescription attributeDescription, Object... values)
Returnstrueif this entry contains all of the attribute values contained invalues. Ifvaluesisnullor empty then this method will returntrueif the attribute is present in this entry, regardless of how many values it contains.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The name of the attribute whose presence in this entry is to be tested.values- The attribute values whose presence in this entry is to be tested, which may benull.- Returns:
trueif this entry contains all of the attribute values contained invalues.- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.NullPointerException- IfattributeDescriptionwasnull.
-
containsAnyAttributes
default boolean containsAnyAttributes(AttributeDescription attributeDescription)
Returnstrueif this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.NOTE: this method performs the matching defined for an LDAP search presence filter. For example, given the attribute description "name" then this method will return
trueif the entry contains "name", "name;option", "cn", or "cn;option". This method is NOT suitable for schema checking, which uses different matching semantics. Specifically, an entry which MUST contain "name" is not valid if it contains "cn", but not "name". See RFC 4512 - Attribute Description Hierarchies.- Parameters:
attributeDescription- The name of the attribute whose presence in this entry is to be tested.- Returns:
trueif this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.- Throws:
NullPointerException- IfattributeDescriptionwasnull.
-
containsAnyAttributes
default boolean containsAnyAttributes(String attributeDescription)
Returnstrueif this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.NOTE: this method performs the matching defined for an LDAP search presence filter. For example, given the attribute description "name" then this method will return
trueif the entry contains "name", "name;option", "cn", or "cn;option". This method is NOT suitable for schema checking, which uses different matching semantics. Specifically, an entry which MUST contain "name" is not valid if it contains "cn", but not "name". See RFC 4512 - Attribute Description Hierarchies.- Parameters:
attributeDescription- The name of the attribute whose presence in this entry is to be tested.- Returns:
trueif this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.- Throws:
NullPointerException- IfattributeDescriptionwasnull.
-
equals
boolean equals(Object object)
Returnstrueifobjectis an entry which is equal to this entry. Two entries are considered equal if their distinguished names are equal, they both have the same number of attributes, and every attribute contained in the first entry is also contained in the second entry.
-
getAllAttributes
Iterable<Attribute> getAllAttributes()
Returns anIterablecontaining all of the attributes in this entry. The returnedIterablemay be used to remove attributes if permitted by this entry.- Returns:
- An
Iterablecontaining all of the attributes.
-
getAllAttributes
default Iterable<Attribute> getAllAttributes(AttributeDescription attributeDescription)
Returns anIterablecontaining all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description. The returnedIterablemay be used to remove attributes if permitted by this entry.- Parameters:
attributeDescription- The name of the attributes to be returned.- Returns:
- An
Iterablecontaining the matching attributes. - Throws:
NullPointerException- IfattributeDescriptionwasnull.
-
getAllAttributes
default Iterable<Attribute> getAllAttributes(String attributeDescription)
Returns anIterablecontaining all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description. The returnedIterablemay be used to remove attributes if permitted by this entry.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
- Parameters:
attributeDescription- The name of the attributes to be returned.- Returns:
- An
Iterablecontaining the matching attributes. - Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.NullPointerException- IfattributeDescriptionwasnull.
-
getAttribute
default Attribute getAttribute(AttributeDescription attributeDescription)
Returns the named attribute contained in this entry, ornullif it is not included with this entry.- Parameters:
attributeDescription- The name of the attribute to be returned.- Returns:
- The named attribute, or
nullif it is not included with this entry. - Throws:
NullPointerException- IfattributeDescriptionwasnull.
-
getAttribute
default Attribute getAttribute(String attributeDescription)
Returns the named attribute contained in this entry, ornullif it is not included with this entry.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
- Parameters:
attributeDescription- The name of the attribute to be returned.- Returns:
- The named attribute, or
nullif it is not included with this entry. - Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.NullPointerException- IfattributeDescriptionwasnull.
-
getAttributeCount
int getAttributeCount()
Returns the number of attributes in this entry.- Returns:
- The number of attributes.
-
getName
Dn getName()
Returns the distinguished name of this entry.- Returns:
- The distinguished name of this entry.
-
hashCode
int hashCode()
Returns the hash code for this entry. It will be calculated as the sum of the hash codes of the distinguished name and all of the attributes.
-
mergeAttribute
default Attribute mergeAttribute(Attribute attribute, BiFunction<? super Attribute,? super Attribute,? extends Attribute> mergeFunction)
Adds the provided attribute if it is not already present in this Entry. Otherwise, replaces the existing attribute with the results of the remapping function, or removes it if the result isnull.NOTE: this method is equivalent to
Map.merge(Object, Object, BiFunction).- Parameters:
attribute- The non-nullattribute to be added or merged with the existing attribute.mergeFunction- The function to recompute the attribute if it is already present in this Entry.- Returns:
- The attribute that was added or merged, or
nullif the attribute was removed. - Throws:
UnsupportedOperationException- If this entry does not permit attributes or their values to be removed.NullPointerException- IfattributeorremappingFunctionwasnull.
-
parseAttribute
default AttributeParser parseAttribute(AttributeDescription attributeDescription)
Returns a parser for the named attribute contained in this entry.- Parameters:
attributeDescription- The name of the attribute to be parsed.- Returns:
- A parser for the named attribute.
- Throws:
NullPointerException- IfattributeDescriptionwasnull.
-
parseAttribute
default AttributeParser parseAttribute(String attributeDescription)
Returns a parser for the named attribute contained in this entry.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
- Parameters:
attributeDescription- The name of the attribute to be parsed.- Returns:
- A parser for the named attribute.
- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.NullPointerException- IfattributeDescriptionwasnull.
-
removeAttribute
default boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues)
Removes all of the attribute values contained inattributefrom this entry if it is present (optional operation). Ifattributeis empty then the entire attribute will be removed if it is present.NOTE: This method implements LDAP Modify delete semantics.
- Parameters:
attribute- The attribute values to be removed from this entry, which may be empty if the entire attribute is to be removed.missingValues- A collection into which missing values will be added, ornullif missing values should not be saved.- Returns:
trueif this entry changed as a result of this call.- Throws:
UnsupportedOperationException- If this entry does not permit attributes or their values to be removed.NullPointerException- Ifattributewasnull.
-
removeAttribute
default boolean removeAttribute(AttributeDescription attributeDescription)
Removes the named attribute from this entry if it is present (optional operation). If this attribute does not contain the attribute, the call leaves this entry unchanged and returnsfalse.- Parameters:
attributeDescription- The name of the attribute to be removed.- Returns:
trueif this entry changed as a result of this call.- Throws:
UnsupportedOperationException- If this entry does not permit attributes to be removed.NullPointerException- IfattributeDescriptionwasnull.
-
removeAttribute
default Entry removeAttribute(String attributeDescription, Object... values)
Removes all of the attribute values contained invaluesfrom the named attribute in this entry if it is present (optional operation). Ifvaluesisnullor empty then the entire attribute will be removed if it is present.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.NOTE: This method implements LDAP Modify delete semantics.
- Parameters:
attributeDescription- The name of the attribute whose values are to be removed.values- The attribute values to be removed from this entry, which may benullor empty if the entire attribute is to be removed.- Returns:
- This entry.
- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.UnsupportedOperationException- If this entry does not permit attributes or their values to be removed.NullPointerException- IfattributeDescriptionwasnull.
-
replaceAttribute
default boolean replaceAttribute(Attribute attribute)
Adds all of the attribute values contained inattributeto this entry, replacing any existing attribute values (optional operation). Ifattributeis empty then the entire attribute will be removed if it is present.NOTE: This method implements LDAP Modify replace semantics as described in RFC 4511 - Section 4.6. Modify Operation.
- Parameters:
attribute- The attribute values to be added to this entry, replacing any existing attribute values, and which may be empty if the entire attribute is to be removed.- Returns:
trueif this entry changed as a result of this call.- Throws:
UnsupportedOperationException- If this entry does not permit attributes or their values to be replaced.NullPointerException- Ifattributewasnull.
-
replaceAttribute
default Entry replaceAttribute(String attributeDescription, Object... values)
Adds all of the attribute values contained invaluesto this entry, replacing any existing attribute values (optional operation). Ifvaluesisnullor empty then the entire attribute will be removed if it is present.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.NOTE: This method implements LDAP Modify replace semantics as described in RFC 4511 - Section 4.6. Modify Operation.
- Parameters:
attributeDescription- The name of the attribute whose values are to be replaced.values- The attribute values to be added to this entry, replacing any existing attribute values, and which may benullor empty if the entire attribute is to be removed.- Returns:
- This entry.
- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the schema associated with this entry.UnsupportedOperationException- If this entry does not permit attributes or their values to be replaced.NullPointerException- Ifattributewasnull.
-
setName
default Entry setName(Dn dn)
Sets the distinguished name of this entry (optional operation).- Parameters:
dn- The distinguished name.- Returns:
- This entry.
- Throws:
UnsupportedOperationException- If this entry does not permit the distinguished name to be set.NullPointerException- Ifdnwasnull.
-
setName
default Entry setName(String dn)
Sets the distinguished name of this entry (optional operation).The distinguished name will be decoded using the schema associated with this entry (usually the default schema).
- Parameters:
dn- The string representation of the distinguished name.- Returns:
- This entry.
- Throws:
LocalizedIllegalArgumentException- Ifdncould not be decoded using the schema associated with this entry.UnsupportedOperationException- If this entry does not permit the distinguished name to be set.NullPointerException- Ifdnwasnull.
-
-