Class DITCacheMap<T>

java.lang.Object
java.util.AbstractMap<Dn,T>
org.opends.server.api.DITCacheMap<T>
Type Parameters:
T - arbitrary object type.
All Implemented Interfaces:
Map<Dn,T>

public final class DITCacheMap<T> extends AbstractMap<Dn,T>
The DITCacheMap class implements custom Map for structural storage of arbitrary objects in Directory Information Tree (DIT) like structure.

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.

  • Constructor Details

    • DITCacheMap

      public DITCacheMap()
      Default constructor.
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Map<Dn,T>
      Overrides:
      size in class AbstractMap<Dn,T>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<Dn,T>
      Overrides:
      isEmpty in class AbstractMap<Dn,T>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<Dn,T>
      Overrides:
      containsKey in class AbstractMap<Dn,T>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<Dn,T>
      Overrides:
      containsValue in class AbstractMap<Dn,T>
    • get

      public T get(Object key)
      Specified by:
      get in interface Map<Dn,T>
      Overrides:
      get in class AbstractMap<Dn,T>
    • getBaseDn

      public Dn getBaseDn(Dn entryDn)
      Find the Base DN of the provided DN.
      Parameters:
      entryDn - The DN of the entry for which to retrieve the corresponding base DN.
      Returns:
      The base DN if found, null otherwise.
    • childrenIterator

      public Iterator<Map.Entry<Dn,T>> childrenIterator(Dn baseDn)
      Returns a filtered-view of this map containing only the immediate children of base-dn.
      Parameters:
      baseDn - The base-dn
      Returns:
      A read-only Iterator on this map returning only immediate children of baseDn. Invoking Iterator.remove() will throw an UnsupportedOperationException.
    • getSubtreeValues

      public Collection<T> getSubtreeValues(Dn key)
      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
    • getChildrenDns

      public List<Dn> getChildrenDns(Dn key, long maxNumberOfChildren)
      Returns the list of the children's DNs, size bounded. To return the whole list, maxNumberOfChildren should be 0.
      Parameters:
      key - the parent DN
      maxNumberOfChildren - the maximum number of children to return, 0 for all
      Returns:
      the list of children dn
    • hasChildren

      public boolean hasChildren(Dn key)
      Returns true if there are objects below the DN, excluding the DN itself.
      Parameters:
      key - subtree DN
      Returns:
      true if there are objects below the DN, excluding the DN itself
    • put

      public T put(Dn key, T value)
      Specified by:
      put in interface Map<Dn,T>
      Overrides:
      put in class AbstractMap<Dn,T>
    • remove

      public T remove(Object key)
      Specified by:
      remove in interface Map<Dn,T>
      Overrides:
      remove in class AbstractMap<Dn,T>
    • containsSubtree

      public boolean containsSubtree(Dn key)
      Returns true if there are stored objects associated with the subtree having the provided base DN.
      Parameters:
      key - the subtree DN.
      Returns:
      true if there are stored objects associated with the subtree having the provided base DN
    • removeSubtree

      public boolean removeSubtree(Dn key, Collection<? super T> removedValues)
      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, or null.
      Returns:
      true if the map changed as a result of calling this method, false otherwise.
    • putAll

      public void putAll(Map<? extends Dn,? extends T> m)
      Specified by:
      putAll in interface Map<Dn,T>
      Overrides:
      putAll in class AbstractMap<Dn,T>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<Dn,T>
      Overrides:
      clear in class AbstractMap<Dn,T>
    • entrySet

      public Set<Map.Entry<Dn,T>> entrySet()
      Specified by:
      entrySet in interface Map<Dn,T>
      Specified by:
      entrySet in class AbstractMap<Dn,T>