Class DITCacheMap<T>
- Type Parameters:
T- arbitrary object type.
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 : object3
then invoking a subtree method on this Map with any of these keys:
ou=Objects,dc=example,dc=com dc=example,dc=com dc=com
would 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()closestSubordinatesIterator(Dn ancestorDn) Returns a filtered-view of this map containing only the entries which are the closest subordinates of the provided ancestorDn.computeChildrenDns(Dn parentDn, int maxNumberOfChildren) Computes the children DNs of the provided parent DN only if subordinate DNs exist for them in the map.booleancontainsKey(Object key) booleancontainsSubtree(Dn key) Returnstrueif there are stored objects associated with the subtree having the provided base DN.booleancontainsValue(Object value) entrySet()Find the Base DN of the provided DN.getWholeSubtreeValues(Dn key) Returns values from the stored objects associated with the subtree having the provided base DN.booleanhasSubordinate(Dn ancestorDn) Returnstrueif there are DNs below the providedancestorDn, excluding theancestorDnitself.booleanisEmpty()voidvoidremoveWholeSubtree(Dn key, Collection<? super T> removedValues) Removes the stored objects associated with the subtree having the provided base DN.intsize()Methods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
DITCacheMap
public DITCacheMap()
-
-
Method Details
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<Dn,T> - Overrides:
containsKeyin classAbstractMap<Dn,T>
-
containsValue
- Specified by:
containsValuein interfaceMap<Dn,T> - Overrides:
containsValuein classAbstractMap<Dn,T>
-
get
-
getBaseDn
-
closestSubordinatesIterator
Returns a filtered-view of this map containing only the entries which are the closest subordinates of the provided ancestorDn. Those entries could have a dn which is a child or a subordinate of the provided ancestorDn.- Parameters:
ancestorDn- The subtree ancestorDn. The ancestorDn does not have to exist in this map.- Returns:
- A read-only
Iteratoron this map returning only entries which are the closest subordinates ofancestorDn.ancestorDnis the common ancestor to all entries returned by the iterator.Iterator.remove()will throw anUnsupportedOperationException.
-
getWholeSubtreeValues
Returns values from the stored objects associated with the subtree having the provided base DN.- Parameters:
key- subtree DN.- Returns:
- values from the stored objects associated with the subtree having the provided base DN
-
computeChildrenDns
Computes the children DNs of the provided parent DN only if subordinate DNs exist for them in the map.Example, if this map contains:
dc=com uid=user.0,ou=people,dc=org-foo,dc=com uid=user.1,ou=people,dc=org-foo,dc=com cn=admin,ou=groups,dc=org-bar,dc=com
then:computeChildren(dc=com) -> [dc=org-foo,dc=com - dc=org-bar,dc=com] computeChildren(dc=org-foo,dc=com) -> [ ] computeChildren(uid=user.0,ou=people,dc=org-foo,dc=com) -> [ ]
- Parameters:
parentDn- the parent DNmaxNumberOfChildren- the maximum number of children to return, 0 means no limit- Returns:
- the list through the unique children dns, which might be empty if this map does not contain the provided parentDn nor subordinates.
-
hasSubordinate
Returnstrueif there are DNs below the providedancestorDn, excluding theancestorDnitself.- Parameters:
ancestorDn- subtreeancestorDn. TheancestorDndoes not have to exist in this map- Returns:
trueif this map contains a subordinate DN of theancestorDn, excluding theancestorDnitself
-
put
-
remove
-
containsSubtree
Returnstrueif there are stored objects associated with the subtree having the provided base DN.- Parameters:
key- the subtree DN.- Returns:
trueif there are stored objects associated with the subtree having the provided base DN
-
removeWholeSubtree
Removes the stored objects associated with the subtree having the provided base DN.- Parameters:
key- subtree DN.removedValues- Collection in which to put the removed elements, ornull.
-
putAll
-
clear
-
entrySet
-