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 forNodeLoaderFactory
implementations that wish to handle missing node loaders in theNodeLoaderFactory.createNodeLoader(Object)
method differently. Normally this should result in anItemNotFoundException
, 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 anUnsupportedOperationException
ifcreateRootNode(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 Summary
Constructors Constructor Description NullNodeLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Node
createForwardNode(DbControl dc, OverviewContext context, Node parentNode)
Create a forward-loading (from parent to child) node for the given parent node.Node
createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
Create a property node for the given parent node.Node
createReverseNode(DbControl dc, OverviewContext context, Node childNode)
Create a reverse-loading (from child to parent) node for the given child node.Node
createRootNode(DbControl dc, OverviewContext context, I item)
Create a root node for the given item.boolean
loadChildNodes(DbControl dc, OverviewContext context, Node node)
Load child nodes of the current node unless they have been loaded already.
-
-
-
Method Detail
-
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 interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextparentNode
- 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 beChildNodeDirection.PROPERTY
in case the property has sub-properties. One example is theProtocolLoader
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 interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextparentNode
- 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 interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextchildNode
- 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 isChildNodeDirection.ALL
so that both forward and reverse child nodes are loaded.- Specified by:
createRootNode
in interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextitem
- 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 theNode.getChildNodeDirection()
of the node.- Specified by:
loadChildNodes
in interfaceNodeLoader<I>
- Parameters:
dc
- The DbControl to use for database accesscontext
- The overview contextnode
- The node- Returns:
- Always "false"
-
-