Class TreeMapEntry
- java.lang.Object
-
- org.forgerock.opendj.ldap.AbstractEntry
-
- org.forgerock.opendj.ldap.AbstractMapEntry<TreeMap<AttributeDescription,Attribute>>
-
- org.forgerock.opendj.ldap.TreeMapEntry
-
- All Implemented Interfaces:
Entry
public final class TreeMapEntry extends AbstractMapEntry<TreeMap<AttributeDescription,Attribute>>
An implementation of theEntry
interface which uses aTreeMap
for storing attributes. Attributes are returned in ascending order of attribute description, withobjectClass
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 theAbstractMapEntry.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, theAbstractMapEntry.removeAttribute(org.forgerock.opendj.ldap.Attribute, java.util.Collection<? super org.forgerock.opendj.ldap.ByteString>)
methods remove the specified values from the existing attribute. TheAbstractMapEntry.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 Summary
Constructors Constructor Description TreeMapEntry()
Creates 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsAnyAttributes(AttributeDescription attributeDescription)
Returnstrue
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 anIterable
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.-
Methods inherited from class org.forgerock.opendj.ldap.AbstractMapEntry
addAttribute, addAttributeIfAbsent, clearAttributes, getAllAttributes, getAttribute, getAttributeCount, getName, mergeAttribute, removeAttribute, replaceAttribute, setName
-
Methods inherited from class org.forgerock.opendj.ldap.AbstractEntry
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.forgerock.opendj.ldap.Entry
addAttribute, addAttribute, containsAnyAttributes, containsAttribute, containsAttribute, containsAttribute, getAllAttributes, getAttribute, parseAttribute, parseAttribute, removeAttribute, removeAttribute, replaceAttribute, setName
-
-
-
-
Constructor Detail
-
TreeMapEntry
public TreeMapEntry()
Creates an entry with an empty (root) distinguished name and no attributes.
-
TreeMapEntry
public TreeMapEntry(Dn name)
Creates an empty entry using the provided distinguished name and no attributes.- Parameters:
name
- The distinguished name of this entry.- Throws:
NullPointerException
- Ifname
wasnull
.
-
TreeMapEntry
public TreeMapEntry(String name)
Creates an empty entry using the provided distinguished name decoded using the default schema.- Parameters:
name
- The distinguished name of this entry.- Throws:
LocalizedIllegalArgumentException
- Ifname
could not be decoded using the default schema.NullPointerException
- Ifname
wasnull
.
-
TreeMapEntry
public TreeMapEntry(String... ldifLines)
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:
LocalizedIllegalArgumentException
- IfldifLines
was empty, or contained invalid LDIF, or could not be decoded using the default schema.NullPointerException
- IfldifLines
wasnull
.
-
-
Method Detail
-
deepCopyOfEntry
public static TreeMapEntry deepCopyOfEntry(Entry entry)
Creates an entry having the same distinguished name, attributes, and object classes of the provided entry. This constructor performs a deep copy ofentry
and will copy each attribute as aLinkedAttribute
.A shallow copy factory method is provided by
shallowCopyOfEntry(Entry)
.- Parameters:
entry
- The entry to be copied.- Returns:
- A deep copy of
entry
. - Throws:
NullPointerException
- Ifentry
wasnull
.- See Also:
shallowCopyOfEntry(Entry)
-
shallowCopyOfEntry
public static TreeMapEntry shallowCopyOfEntry(Entry entry)
Creates an entry having the same distinguished name, attributes, and object classes of the provided entry. This constructor performs a shallow copy ofentry
and will not copy the attributes contained inentry
.A deep copy factory method is provided by
deepCopyOfEntry(Entry)
- Parameters:
entry
- The entry to be copied.- Returns:
- A shallow copy of
entry
. - Throws:
NullPointerException
- Ifentry
wasnull
.- See Also:
deepCopyOfEntry(Entry)
-
containsAnyAttributes
public boolean containsAnyAttributes(AttributeDescription attributeDescription)
Description copied from interface:Entry
Returnstrue
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.- Parameters:
attributeDescription
- The name of the attribute whose presence in this entry is to be tested.- Returns:
true
if this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.
-
getAllAttributes
public Iterable<Attribute> getAllAttributes(AttributeDescription attributeDescription)
Description copied from interface:Entry
Returns anIterable
containing all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description. The returnedIterable
may be used to remove attributes if permitted by this entry.- Parameters:
attributeDescription
- The name of the attributes to be returned.- Returns:
- An
Iterable
containing the matching attributes.
-
-