public final class TreeMapEntry extends AbstractEntry
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 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 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.
Modifier and Type | Field and Description |
---|---|
static EntryFactory |
FACTORY
An entry factory which can be used to create new tree map entries.
|
Constructor and Description |
---|
TreeMapEntry()
Creates an entry with an empty (root) distinguished name and no
attributes.
|
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.
|
TreeMapEntry(String... ldifLines)
Creates a new entry using the provided lines of LDIF decoded using the
default schema.
|
TreeMapEntry(String name)
Creates an empty entry using the provided distinguished name decoded
using the default schema.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAttribute(Attribute attribute,
Collection<? super ByteString> duplicateValues)
Ensures that this entry contains the provided attribute and values
(optional operation).
|
Entry |
clearAttributes()
Removes all the attributes from this entry (optional operation).
|
static TreeMapEntry |
deepCopyOfEntry(Entry entry)
Creates an entry having the same distinguished name, attributes, and
object classes of the provided entry.
|
Iterable<Attribute> |
getAllAttributes()
Returns an
Iterable containing all of the attributes in this
entry. |
Attribute |
getAttribute(AttributeDescription attributeDescription)
Returns the named attribute contained in this entry, or
null if
it is not included with this entry. |
int |
getAttributeCount()
Returns the number of attributes in this entry.
|
Dn |
getName()
Returns the string representation of the distinguished name of this
entry.
|
boolean |
removeAttribute(Attribute attribute,
Collection<? super ByteString> missingValues)
Removes all of the attribute values contained in
attribute from
this entry if it is present (optional operation). |
Entry |
setName(Dn dn)
Sets the distinguished name of this entry (optional operation).
|
addAttribute, addAttribute, containsAttribute, containsAttribute, equals, getAllAttributes, getAllAttributes, getAttribute, hashCode, parseAttribute, parseAttribute, removeAttribute, removeAttribute, replaceAttribute, replaceAttribute, setName, toString
public static final EntryFactory FACTORY
public TreeMapEntry()
public TreeMapEntry(Dn name)
name
- The distinguished name of this entry.NullPointerException
- If name
was null
.public TreeMapEntry(Entry entry)
entry
and will not copy the attributes contained in
entry
.
A deep copy constructor is provided by TreeMapEntry.deepCopyOfEntry(Entry)
entry
- The entry to be copied.NullPointerException
- If entry
was null
.TreeMapEntry.deepCopyOfEntry(Entry)
public TreeMapEntry(String name)
name
- The distinguished name of this entry.org.forgerock.i18n.LocalizedIllegalArgumentException
- If name
could not be decoded using the default
schema.NullPointerException
- If name
was null
.public TreeMapEntry(String... ldifLines)
ldifLines
- Lines of LDIF containing the an LDIF add change record or an
LDIF entry record.org.forgerock.i18n.LocalizedIllegalArgumentException
- If ldifLines
was empty, or contained invalid LDIF, or
could not be decoded using the default schema.NullPointerException
- If ldifLines
was null
.public static TreeMapEntry deepCopyOfEntry(Entry entry)
entry
and will copy each attribute as a
LinkedAttribute
.
A shallow copy constructor is provided by TreeMapEntry.TreeMapEntry(Entry)
.
entry
- The entry to be copied.entry
.NullPointerException
- If entry
was null
.TreeMapEntry.TreeMapEntry(Entry)
public final boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues)
Entry
matching
attribute description, then
this entry will be modified such that it contains attribute
, even
if it is empty.
matching
attribute description, then
the attribute values contained in attribute
will be merged with
the existing attribute values.
NOTE: When attribute
is non-empty, this method implements
LDAP Modify add semantics.
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, or
null
if duplicate values should not be saved.true
if this entry changed as a result of this call.public final Entry clearAttributes()
Entry
public final Iterable<Attribute> getAllAttributes()
Entry
Iterable
containing all of the attributes in this
entry. The returned Iterable
may be used to remove attributes if
permitted by this entry.Iterable
containing all of the attributes.public final Attribute getAttribute(AttributeDescription attributeDescription)
Entry
null
if
it is not included with this entry.getAttribute
in interface Entry
getAttribute
in class AbstractEntry
attributeDescription
- The name of the attribute to be returned.null
if it is not included with
this entry.public final int getAttributeCount()
Entry
public final Dn getName()
Entry
public final boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues)
Entry
attribute
from
this entry if it is present (optional operation). If attribute
is
empty then the entire attribute will be removed if it is present.
NOTE: This method implements LDAP Modify delete semantics.
removeAttribute
in interface Entry
removeAttribute
in class AbstractEntry
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, or
null
if missing values should not be saved.true
if this entry changed as a result of this call.Copyright © 2010-2020, ForgeRock All Rights Reserved.