public final class TreeMapEntry extends AbstractMapEntry<TreeMap<AttributeDescription,Attribute>>
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 AbstractMapEntry.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 AbstractMapEntry.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 AbstractMapEntry.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.
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(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 |
containsAnyAttributes(AttributeDescription attributeDescription)
Returns
true if this entry contains any non-empty attributes having an attribute description which is
a sub-type of the provided attribute description. |
static TreeMapEntry |
deepCopyOfEntry(Entry entry)
Creates an entry having the same distinguished name, attributes, and object classes of the provided entry.
|
Iterable<Attribute> |
getAllAttributes(AttributeDescription attributeDescription)
Returns an
Iterable containing all the attributes in this entry having an attribute description which is
a sub-type of the provided attribute description. |
static TreeMapEntry |
shallowCopyOfEntry(Entry entry)
Creates an entry having the same distinguished name, attributes, and object classes of the provided entry.
|
addAttribute, addAttributeIfAbsent, clearAttributes, getAllAttributes, getAttribute, getAttributeCount, getName, mergeAttribute, removeAttribute, replaceAttribute, setName
equals, hashCode, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAttribute, addAttribute, containsAnyAttributes, containsAttribute, containsAttribute, containsAttribute, getAllAttributes, getAttribute, parseAttribute, parseAttribute, removeAttribute, removeAttribute, replaceAttribute, setName
public TreeMapEntry()
public TreeMapEntry(Dn name)
name
- The distinguished name of this entry.NullPointerException
- If name
was null
.public TreeMapEntry(String name)
name
- The distinguished name of this entry.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.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 factory method is provided by shallowCopyOfEntry(Entry)
.
entry
- The entry to be copied.entry
.NullPointerException
- If entry
was null
.shallowCopyOfEntry(Entry)
public static TreeMapEntry shallowCopyOfEntry(Entry entry)
entry
and will not copy the attributes contained in entry
.
A deep copy factory method is provided by deepCopyOfEntry(Entry)
entry
- The entry to be copied.entry
.NullPointerException
- If entry
was null
.deepCopyOfEntry(Entry)
public boolean containsAnyAttributes(AttributeDescription attributeDescription)
Entry
true
if 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 true
if 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.
attributeDescription
- The name of the attribute whose presence in this entry is to be tested.true
if this entry contains any non-empty attributes having an attribute description which is a
sub-type of the provided attribute description.public Iterable<Attribute> getAllAttributes(AttributeDescription attributeDescription)
Entry
Iterable
containing all the attributes in this entry having an attribute description which is
a sub-type of the provided attribute description. The returned Iterable
may be used to remove attributes
if permitted by this entry.attributeDescription
- The name of the attributes to be returned.Iterable
containing the matching attributes.Copyright 2010-2022 ForgeRock AS.