Class TreeMapEntry
- All Implemented Interfaces:
Entry
Entry interface which uses a TreeMap
for storing attributes. Attributes are returned in ascending order of
attribute description, with objectClass first, then all user
attributes, and finally any operational attributes. All operations are
supported by this implementation. For example, you can build an entry like
this:
Entry entry = new TreeMapEntry("cn=Bob,ou=People,dc=example,dc=com")
.addAttribute("cn", "Bob")
.addAttribute("objectclass", "top")
.addAttribute("objectclass", "person")
.addAttribute("objectclass", "organizationalPerson")
.addAttribute("objectclass", "inetOrgPerson")
.addAttribute("mail", "subgenius@example.com")
.addAttribute("sn", "Dobbs");
A TreeMapEntry stores references to attributes which have been added
using the Entry.addAttribute(org.forgerock.opendj.ldap.Attribute, java.util.Collection<? super org.forgerock.opendj.ldap.ByteString>) methods. Attributes sharing the same
attribute description are merged by adding the values of the new attribute to
the existing attribute. More specifically, the existing attribute must be
modifiable for the merge to succeed. Similarly, the AbstractEntry.removeAttribute(org.forgerock.opendj.ldap.Attribute, java.util.Collection<? super org.forgerock.opendj.ldap.ByteString>)
methods remove the specified values from the existing attribute. The
AbstractEntry.replaceAttribute(org.forgerock.opendj.ldap.Attribute) methods remove the existing attribute (if present)
and store a reference to the new attribute - neither the new or existing
attribute need to be modifiable in this case.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EntryFactoryAn entry factory which can be used to create new tree map entries. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an entry with an empty (root) distinguished name and no attributes.TreeMapEntry(String name) Creates an empty entry using the provided distinguished name decoded using the default schema.TreeMapEntry(String... ldifLines) Creates a new entry using the provided lines of LDIF decoded using the default schema.TreeMapEntry(DN name) Creates an empty entry using the provided distinguished name and no attributes.TreeMapEntry(Entry entry) Creates an entry having the same distinguished name, attributes, and object classes of the provided entry. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanaddAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues) Ensures that this entry contains the provided attribute and values (optional operation).final EntryRemoves all the attributes from this entry (optional operation).static TreeMapEntrydeepCopyOfEntry(Entry entry) Creates an entry having the same distinguished name, attributes, and object classes of the provided entry.Returns anIterablecontaining all of the attributes in this entry.final AttributegetAttribute(AttributeDescription attributeDescription) Returns the named attribute contained in this entry, ornullif it is not included with this entry.final intReturns the number of attributes in this entry.final DNgetName()Returns the string representation of the distinguished name of this entry.final booleanremoveAttribute(Attribute attribute, Collection<? super ByteString> missingValues) Removes all of the attribute values contained inattributefrom this entry if it is present (optional operation).final EntrySets the distinguished name of this entry (optional operation).Methods inherited from class org.forgerock.opendj.ldap.AbstractEntry
addAttribute, addAttribute, containsAttribute, containsAttribute, equals, getAllAttributes, getAllAttributes, getAttribute, hashCode, parseAttribute, parseAttribute, removeAttribute, removeAttribute, replaceAttribute, replaceAttribute, setName, toString
-
Field Details
-
FACTORY
An entry factory which can be used to create new tree map entries.
-
-
Constructor Details
-
TreeMapEntry
public TreeMapEntry()Creates an entry with an empty (root) distinguished name and no attributes. -
TreeMapEntry
Creates an empty entry using the provided distinguished name and no attributes.- Parameters:
name- The distinguished name of this entry.- Throws:
NullPointerException- Ifnamewasnull.
-
TreeMapEntry
Creates an entry having the same distinguished name, attributes, and object classes of the provided entry. This constructor performs a shallow copy ofentryand will not copy the attributes contained inentry.A deep copy constructor is provided by
deepCopyOfEntry(Entry)- Parameters:
entry- The entry to be copied.- Throws:
NullPointerException- Ifentrywasnull.- See Also:
-
TreeMapEntry
Creates an empty entry using the provided distinguished name decoded using the default schema.- Parameters:
name- The distinguished name of this entry.- Throws:
org.forgerock.i18n.LocalizedIllegalArgumentException- Ifnamecould not be decoded using the default schema.NullPointerException- Ifnamewasnull.
-
TreeMapEntry
Creates a new entry using the provided lines of LDIF decoded using the default schema.- Parameters:
ldifLines- Lines of LDIF containing the an LDIF add change record or an LDIF entry record.- Throws:
org.forgerock.i18n.LocalizedIllegalArgumentException- IfldifLineswas empty, or contained invalid LDIF, or could not be decoded using the default schema.NullPointerException- IfldifLineswasnull.
-
-
Method Details
-
deepCopyOfEntry
Creates an entry having the same distinguished name, attributes, and object classes of the provided entry. This constructor performs a deep copy ofentryand will copy each attribute as aLinkedAttribute.A shallow copy constructor is provided by
TreeMapEntry(Entry).- Parameters:
entry- The entry to be copied.- Returns:
- A deep copy of
entry. - Throws:
NullPointerException- Ifentrywasnull.- See Also:
-
addAttribute
public final boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues) Description copied from interface:EntryEnsures 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.
- If this entry does not already contain an attribute with a
-
clearAttributes
Description copied from interface:EntryRemoves all the attributes from this entry (optional operation).- Returns:
- This entry.
-
getAllAttributes
Description copied from interface:EntryReturns 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.
-
getAttribute
Description copied from interface:EntryReturns the named attribute contained in this entry, ornullif it is not included with this entry.- Specified by:
getAttributein interfaceEntry- Overrides:
getAttributein classAbstractEntry- Parameters:
attributeDescription- The name of the attribute to be returned.- Returns:
- The named attribute, or
nullif it is not included with this entry.
-
getAttributeCount
public final int getAttributeCount()Description copied from interface:EntryReturns the number of attributes in this entry.- Returns:
- The number of attributes.
-
getName
Description copied from interface:EntryReturns the string representation of the distinguished name of this entry.- Returns:
- The string representation of the distinguished name.
-
removeAttribute
public final boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues) Description copied from interface:EntryRemoves 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.
- Specified by:
removeAttributein interfaceEntry- Overrides:
removeAttributein classAbstractEntry- 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.
-
setName
Description copied from interface:EntrySets the distinguished name of this entry (optional operation).- Parameters:
dn- The distinguished name.- Returns:
- This entry.
-