T
- arbitrary object type.public final class DITCacheMap<T> extends AbstractMap<Dn,T>
This Map intended usage is for caching various server objects which can be subject to subtree operations like retrieval or removal of all objects under a specific DN. While using a regular Map it would require the entire Map iteration to achieve, this Map implementation maintains such internal structure that subtree operations are more efficient and do not require iterations over the entire map, instead additional subtree operations methods are provided by this Map to do just that.
API wise it behaves exactly like a regular Map implementation except for providing additional subtree methods. All required linkage and structuring is performed within this Map implementation itself and not exposed via the API in any way. For example, putting these key/value pairs:
cn=Object1,ou=Objects,dc=example,dc=com : object1 cn=Object2,ou=Objects,dc=example,dc=com : object2 cn=Object3,ou=Objects,dc=example,dc=com : object3then invoking a subtree method on this Map with any of these keys:
ou=Objects,dc=example,dc=com dc=example,dc=com dc=comwould bring all three objects previously stored in this map into subtree operation scope. Standard Map API methods can only work with the objects previously stored in this map explicitly.
Note that this Map implementation is not synchronized.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
DITCacheMap()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
Iterator<Map.Entry<Dn,T>> |
childrenIterator(Dn baseDn)
Returns a filtered-view of this map containing only the immediate children of base-dn.
|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsSubtree(Dn key)
Returns
true if there are stored objects associated with the subtree having the provided base DN. |
boolean |
containsValue(Object value) |
Set<Map.Entry<Dn,T>> |
entrySet() |
T |
get(Object key) |
Dn |
getBaseDn(Dn entryDn)
Find the Base DN of the provided DN.
|
List<Dn> |
getChildrenDns(Dn key,
long maxNumberOfChildren)
Returns the list of the children's DNs, size bounded.
|
Collection<T> |
getSubtreeValues(Dn key)
Returns values from the stored objects associated with the subtree having the provided base DN.
|
boolean |
hasChildren(Dn key)
Returns
true if there are objects below the DN, excluding the DN itself. |
boolean |
isEmpty() |
T |
put(Dn key,
T value) |
void |
putAll(Map<? extends Dn,? extends T> m) |
T |
remove(Object key) |
boolean |
removeSubtree(Dn key,
Collection<? super T> values)
Removes the stored objects associated with the subtree having the provided base DN.
|
int |
size() |
clone, equals, hashCode, keySet, toString, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey
in interface Map<Dn,T>
containsKey
in class AbstractMap<Dn,T>
public boolean containsValue(Object value)
containsValue
in interface Map<Dn,T>
containsValue
in class AbstractMap<Dn,T>
public Dn getBaseDn(Dn entryDn)
entryDn
- The DN of the entry for which to retrieve the corresponding base DN.null
otherwise.public Iterator<Map.Entry<Dn,T>> childrenIterator(Dn baseDn)
baseDn
- The base-dnIterator
on this map returning only immediate children of baseDn. Invoking
Iterator.remove()
will throw an UnsupportedOperationException
.public Collection<T> getSubtreeValues(Dn key)
key
- subtree DN.public List<Dn> getChildrenDns(Dn key, long maxNumberOfChildren)
maxNumberOfChildren
should be 0.key
- the parent DNmaxNumberOfChildren
- the maximum number of children to return, 0 for allpublic boolean hasChildren(Dn key)
true
if there are objects below the DN, excluding the DN itself.key
- subtree DNtrue
if there are objects below the DN, excluding the DN itselfpublic boolean containsSubtree(Dn key)
true
if there are stored objects associated with the subtree having the provided base DN.key
- the subtree DN.true
if there are stored objects associated with the subtree having the provided base DNpublic boolean removeSubtree(Dn key, Collection<? super T> values)
key
- subtree DN.values
- collection for removed objects subordinate to subtree DN or null
.true
on success or false
otherwise.public void clear()
Copyright 2010-2022 ForgeRock AS.