3.2.1: 2012-12-13

net.sf.basedb.util.overview.validator
Class ExtensionNodeValidator<I>

java.lang.Object
  extended by net.sf.basedb.util.overview.validator.ExtensionNodeValidator<I>
All Implemented Interfaces:
NodeValidator<I>

public class ExtensionNodeValidator<I>
extends Object
implements NodeValidator<I>

Wrapper for node validators that hooks into the extension system when validating nodes. The parent (or core) validator is always invoked first, then the extension system is queried for additional validators. Methods that return a value return the result from the last call (unless nothing else is specified).

Since:
3.2
Author:
Nicklas

Field Summary
private  Object key
           
private  NodeValidator<I> parent
           
private  List<NodeValidatorAction<I>> xtValidators
           
 
Constructor Summary
ExtensionNodeValidator(NodeValidator<I> parent, Object key)
          Wrap the given parent node validator.
 
Method Summary
private  Iterable<NodeValidatorAction<I>> getValidators(DbControl dc)
           
 void postDeniedItem(DbControl dc, OverviewContext context, Node node, Node parentNode)
          Call the same method on the parent validator and then on all extension validator actions.
 void postMissingItem(DbControl dc, OverviewContext context, Node node, Node parentNode)
          Call the same method on the parent validator and then on all extension validator actions.
 void postValidate(DbControl dc, OverviewContext context, Node node, Node parentNode)
          Call the same method on the parent validator and then on all extension validator actions.
 void postValidateFolder(DbControl dc, OverviewContext context, Node folderNode, Node parentNode)
          Call the same method on the parent validator and then on all extension validator actions.
 boolean preDeniedItem(DbControl dc, OverviewContext context, Node parentNode)
          Call the same method on the parent validator and then on all extension validator actions.
 boolean preMissingItem(DbControl dc, OverviewContext context, Node parentNode)
          Call the same method on the parent validator and then on all extension validator actions.
 boolean preValidate(DbControl dc, OverviewContext context, I item, Node parentNode)
          Call the same method on the parent validator and then on all extension validator actions.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

private final NodeValidator<I> parent

key

private final Object key

xtValidators

private List<NodeValidatorAction<I>> xtValidators
Constructor Detail

ExtensionNodeValidator

public ExtensionNodeValidator(NodeValidator<I> parent,
                              Object key)
Wrap the given parent node validator.

Method Detail

preMissingItem

public boolean preMissingItem(DbControl dc,
                              OverviewContext context,
                              Node parentNode)
Call the same method on the parent validator and then on all extension validator actions. The result from the last call is returned.

Specified by:
preMissingItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
parentNode - The parent node that is missing the item
Returns:
TRUE if a node should be created, FALSE if not

preDeniedItem

public boolean preDeniedItem(DbControl dc,
                             OverviewContext context,
                             Node parentNode)
Call the same method on the parent validator and then on all extension validator actions. The result from the last call is returned.

Specified by:
preDeniedItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
parentNode - The parent node that is linked with the item
Returns:
TRUE if a node should be created, FALSE if not

preValidate

public boolean preValidate(DbControl dc,
                           OverviewContext context,
                           I item,
                           Node parentNode)
Call the same method on the parent validator and then on all extension validator actions. The result from the last call is returned.

Specified by:
preValidate in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
item - The item to validate
parentNode - The parent node that is linked with the item
Returns:
TRUE if a node should be created, FALSE if not

postMissingItem

public void postMissingItem(DbControl dc,
                            OverviewContext context,
                            Node node,
                            Node parentNode)
Call the same method on the parent validator and then on all extension validator actions.

Specified by:
postMissingItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
node - The node object that represents the missing item
parentNode - The parent node that is missing the item

postDeniedItem

public void postDeniedItem(DbControl dc,
                           OverviewContext context,
                           Node node,
                           Node parentNode)
Call the same method on the parent validator and then on all extension validator actions.

Specified by:
postDeniedItem in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
node - The node object that represents the unaccessible item
parentNode - The parent node that is linked with the item

postValidate

public void postValidate(DbControl dc,
                         OverviewContext context,
                         Node node,
                         Node parentNode)
Call the same method on the parent validator and then on all extension validator actions.

Specified by:
postValidate in interface NodeValidator<I>
Parameters:
dc - A DbControl to use if the validation needs to access the database
context - The current overview context
node - The node object that represents item
parentNode - The parent node that is linked with the item

postValidateFolder

public void postValidateFolder(DbControl dc,
                               OverviewContext context,
                               Node folderNode,
                               Node parentNode)
Call the same method on the parent validator and then on all extension validator actions.

Specified by:
postValidateFolder in interface NodeValidator<I>
Parameters:
dc - A DbControl to use for database access
context - The current overview context
folderNode - The folder node, or null if no folder has been created
parentNode - The parent node (never null)

toString

public String toString()
Overrides:
toString in class Object

getValidators

private Iterable<NodeValidatorAction<I>> getValidators(DbControl dc)

3.2.1: 2012-12-13