Class AutoChildNodeLoader<I>

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

public class AutoChildNodeLoader<I>
extends Object
implements NodeLoader<I>
Node loader implementation that automatically loads child nodes. When any of the create... methods are called the actual node loading is delegated to a parent node loader. If this loader returns a non-null node, loadChildNodes(DbControl, OverviewContext, Node) is automatically invoked on it.

The automatic loading can of course only be done one step down, since the new children probably needs a different parent node loader. It is possible to make the loading fully recursive by if the NodeLoaderFactory returned from OverviewContext.getNodeLoaderFactory() wrap all node loaders it create by an instance of this class.

Version:
2.10
Author:
Nicklas
Last modified
$Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
  • Field Details

  • Constructor Details

    • AutoChildNodeLoader

      public AutoChildNodeLoader​(NodeLoader<I> parent)
  • Method Details

    • createForwardNode

      public Node createForwardNode​(DbControl dc, OverviewContext context, Node parentNode)
      Call the same method on the 'parent' node loader. If one or more child nodes are added to the parent node, the loadChildNodes(DbControl, OverviewContext, Node) is called for each of the new nodes.
      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:
      The node that the parent node loader creates (may be null)
    • createPropertyNode

      public Node createPropertyNode​(DbControl dc, OverviewContext context, Node parentNode)
      Call the same method on the 'parent' node loader. If one or more child nodes are added to the parent node, the loadChildNodes(DbControl, OverviewContext, Node) is called for each of the new nodes.
      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:
      The node that the parent node loader creates (may be null)
    • createReverseNode

      public Node createReverseNode​(DbControl dc, OverviewContext context, Node childNode)
      Call the same method on the 'parent' node loader. If one or more child nodes are added to the parent node, the loadChildNodes(DbControl, OverviewContext, Node) is called for each of the new nodes.
      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:
      The node that the parent node loader creates (may be null)
    • createRootNode

      public Node createRootNode​(DbControl dc, OverviewContext context, I item)
      Call the same method on the 'parent' node loader. If a node is created loadChildNodes(DbControl, OverviewContext, Node) is called on the new node.
      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:
      The node that the parent node loader creates (may be null)
    • loadChildNodes

      public boolean loadChildNodes​(DbControl dc, OverviewContext context, Node node)
      Call the same method on the 'parent' node loader.
      Specified by:
      loadChildNodes in interface NodeLoader<I>
      Parameters:
      dc - The DbControl to use for database access
      context - The overview context
      node - The node
      Returns:
      The result of the parent call
    • toString

      public String toString()
      Overrides:
      toString in class Object