Class NullNodeLoader<I>

java.lang.Object
net.sf.basedb.util.overview.loader.NullNodeLoader<I>
All Implemented Interfaces:
NodeLoader<I>

public class NullNodeLoader<I> extends Object implements NodeLoader<I>
A node loader implementation that doesn't load any nodes. This may be useful for NodeLoaderFactory implementations that wish to handle missing node loaders in the NodeLoaderFactory.createNodeLoader(Object) method differently. Normally this should result in an ItemNotFoundException, but an alternative approach may be to return this loader which will effectively make an end-point in the node tree. This node loader can't be used for root nodes and will throw an UnsupportedOperationException if createRootNode(DbControl, OverviewContext, Object) is called.
Version:
2.10
Author:
Nicklas
Last modified
$Date: 2012-04-17 12:46:51 +0200 (ti, 17 apr 2012) $
  • Constructor Details

    • NullNodeLoader

      public NullNodeLoader()
  • Method Details

    • createForwardNode

      public Node createForwardNode(DbControl dc, OverviewContext context, Node parentNode)
      Description copied from interface: NodeLoader
      Create a forward-loading (from parent to child) node for the given parent node. The loader should use the information on the parent node to get the correct item (of type I) and create a node for that item. If the parent can have many child nodes, the loader should first create a folder-type node and put the children inside that.

      The direction of the node(s) should usually be ChildNodeDirection.FORWARD. In case there is an error (permission denied, etc.) ChildNodeDirection.NONE should be used. If there is no child item null should be returned.

      Errors, missing items, etc. should be reported as failures to the OverviewContext.

      Specified by:
      createForwardNode in interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      parentNode - The parent node
      Returns:
      Always "null"
    • createPropertyNode

      public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
      Description copied from interface: NodeLoader
      Create a property node for the given parent node. A property node is a node that is not on the main parent-child path. It is typically a node that can't be used a root node (for example, a protocol or software). If the parent node can have many properties of this type the loader can decide if it should first create a folder-type node and put the children inside the folder, or if all child nodes should be created directly in the parent node. In the first case, the folder node should be returned. In the latter case, null should be returned.

      The direction of the node(s) should usually be ChildNodeDirection.NONE, but it may also be ChildNodeDirection.PROPERTY in case the property has sub-properties. One example is the ProtocolLoader which loads the protocol parameters as child nodes.

      In case there is an error (permission denied, etc.) ChildNodeDirection.NONE should be used. If there is no property item null should be returned (but this may also indicate that more than one node was created).

      Errors, missing items, etc. should be reported as failures to the OverviewContext.

      Specified by:
      createPropertyNode in interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      parentNode - The parent node
      Returns:
      Always "null"
    • createReverseNode

      public Node createReverseNode(DbControl dc, OverviewContext context, Node childNode)
      Description copied from interface: NodeLoader
      Create a reverse-loading (from child to parent) node for the given child node. The loader should use the information on the child node to get the correct item (of type I) and create a node for that item. If the child can have many parent nodes, the loader should first create a folder-type node and put the parents inside that.

      The direction of the node(s) should usually be ChildNodeDirection.REVERSE. In case there is an error (permission denied, etc.) ChildNodeDirection.NONE should be used. If there is no parent item null should be returned.

      Errors, missing items, etc. should be reported as failures to the OverviewContext.

      Specified by:
      createReverseNode in interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      childNode - The child node
      Returns:
      Always "null"
    • createRootNode

      public Node createRootNode(DbControl dc, OverviewContext context, I item)
      Description copied from interface: NodeLoader
      Create a root node for the given item. A root node is a node with no parent. Typically, the direction of the created node is ChildNodeDirection.ALL so that both forward and reverse child nodes are loaded.
      Specified by:
      createRootNode in interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      item - The root item
      Returns:
      A root node
      Throws:
      UnsupportedOperationException - Always
    • loadChildNodes

      public boolean loadChildNodes(DbControl dc, OverviewContext context, Node node)
      Description copied from interface: NodeLoader
      Load child nodes of the current node unless they have been loaded already. Note that which child nodes to load depends on the Node.getChildNodeDirection() of the node.
      Specified by:
      loadChildNodes in interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      node - The node
      Returns:
      Always "false"