Class DirectoryNodeStore<K extends java.io.Serializable,​D extends java.io.Serializable>

  • All Implemented Interfaces:
    NodeStore<K,​java.io.File,​D>

    public class DirectoryNodeStore<K extends java.io.Serializable,​D extends java.io.Serializable>
    extends java.lang.Object
    implements NodeStore<K,​java.io.File,​D>
    A trivial storage class that puts all nodes into a single directory with filenames represented by the hex-encoding of their key names.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.File convert​(K key)
      Convert user keys to store keys.
      java.io.File generateKey​(Node<K,​java.io.File> node, D d)
      Generate a key to store a node or data element.
      D loadData​(java.io.File key)
      Load the user's data.
      Node<K,​java.io.File> loadNode​(java.io.File key)
      Load a node object from NodeStore.
      void removeData​(java.io.File key)
      Remove the given data key.
      void removeNode​(java.io.File key)
      Remove the given node key.
      void store​(java.io.File key, Node<K,​java.io.File> node)
      Store the given node.
      void store​(java.io.File key, D data)
      Store user data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DirectoryNodeStore

        public DirectoryNodeStore​(java.lang.String directory)
      • DirectoryNodeStore

        public DirectoryNodeStore​(java.io.File directory)
    • Method Detail

      • removeNode

        public void removeNode​(java.io.File key)
                        throws NodeStoreException
        Remove the given node key. If the key does not exist, this should return without error.
        Specified by:
        removeNode in interface NodeStore<K extends java.io.Serializable,​java.io.File,​D extends java.io.Serializable>
        Throws:
        NodeStoreException
      • removeData

        public void removeData​(java.io.File key)
                        throws NodeStoreException
        Remove the given data key. If the key does not exist, this should return without error.
        Specified by:
        removeData in interface NodeStore<K extends java.io.Serializable,​java.io.File,​D extends java.io.Serializable>
        Throws:
        NodeStoreException
      • loadData

        public D loadData​(java.io.File key)
                   throws NodeStoreException
        Load the user's data.
        Specified by:
        loadData in interface NodeStore<K extends java.io.Serializable,​java.io.File,​D extends java.io.Serializable>
        Returns:
        the user's data or null if it is not found.
        Throws:
        NodeStoreException
      • store

        public void store​(java.io.File key,
                          Node<K,​java.io.File> node)
                   throws NodeStoreException
        Store the given node. If an object already exists at the key, it should be replaced.
        Specified by:
        store in interface NodeStore<K extends java.io.Serializable,​java.io.File,​D extends java.io.Serializable>
        Throws:
        NodeStoreException
      • store

        public void store​(java.io.File key,
                          D data)
                   throws NodeStoreException
        Store user data. If an object already exists at the key, it should be replaced.
        Specified by:
        store in interface NodeStore<K extends java.io.Serializable,​java.io.File,​D extends java.io.Serializable>
        Throws:
        NodeStoreException
      • generateKey

        public java.io.File generateKey​(Node<K,​java.io.File> node,
                                        D d)
        Generate a key to store a node or data element. This key must be unique.
        Specified by:
        generateKey in interface NodeStore<K extends java.io.Serializable,​java.io.File,​D extends java.io.Serializable>
        Parameters:
        node - This is provided to implementations for some context. If generateKey is being called for the purposes of storing a user key, this will be null.
        d - If a key is being generated for a user key value, it will be passed along. This is most useful when things like a PagedList are adding a value, but the List API does not provide a way to specify a key.
      • convert

        public java.io.File convert​(K key)
                             throws NodeStoreException
        Convert user keys to store keys. This method, given a user's key, must always produce the same store key.
        Specified by:
        convert in interface NodeStore<K extends java.io.Serializable,​java.io.File,​D extends java.io.Serializable>
        Throws:
        NodeStoreException - if any error occurs.