Class BasicItemNodeValidatorFactory
java.lang.Object
net.sf.basedb.util.overview.validator.BasicItemNodeValidatorFactory
- All Implemented Interfaces:
NodeValidatorFactory<BasicItem,
Object>
public class BasicItemNodeValidatorFactory
extends Object
implements NodeValidatorFactory<BasicItem,Object>
Node validator factory implementation for
BasicItem
node validators.
The key used in createNodeValidator(Object)
should normally be
an Item
object.- Version:
- 2.10
- Author:
- Nicklas
- Last modified
- $Date: 2020-10-21 07:39:15 +0200 (Wed, 21 Oct 2020) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionNodeValidator<? extends BasicItem>
Create a new node validator that can validate nodes with items of the specified item type.boolean
Check if node validation has been disabled.protected void
registerCheckedNodeValidator
(Object key, Class<?> validatorClass) Register a node loader implementation that you are sure fulfills the requirements.protected void
Registers default item node validators fromBioSource
toExperiment
, etc.void
registerNodeValidator
(Item key, Class<? extends NodeValidator<? extends BasicItem>> validatorClass) Register a node validator implementation.void
setDisabled
(boolean disabled) Disable/enabled node validation programmatically.void
setUsNullValidatorIfNotFound
(boolean useNullValidator) Set a flag that determines if aNullNodeValidator
should be used or if anItemNotFoundException
should be thrown if no registered node validator is found for a specific key.boolean
Get the null validator setting.
-
Field Details
-
validators
-
useNullValidator
private boolean useNullValidator -
disabled
private boolean disabled
-
-
Constructor Details
-
BasicItemNodeValidatorFactory
public BasicItemNodeValidatorFactory()Creates a new factory.
-
-
Method Details
-
isDisabled
public boolean isDisabled()Description copied from interface:NodeValidatorFactory
Check if node validation has been disabled.- Specified by:
isDisabled
in interfaceNodeValidatorFactory<BasicItem,
Object> - Returns:
- TRUE if validation has been disabled
-
setDisabled
public void setDisabled(boolean disabled) Description copied from interface:NodeValidatorFactory
Disable/enabled node validation programmatically. When a node validator factory is disabled theNodeValidatorFactory.createNodeValidator(Object)
should return null or aNullNodeValidator
for all requests.- Specified by:
setDisabled
in interfaceNodeValidatorFactory<BasicItem,
Object> - Parameters:
disabled
- TRUE to disable node validation
-
createNodeValidator
Create a new node validator that can validate nodes with items of the specified item type. If no validator has been registered for the given item type, aNullNodeValidator
is returned or an exception is thrown depending on theuseNullValidatorIfNotFound()
option.- Specified by:
createNodeValidator
in interfaceNodeValidatorFactory<BasicItem,
Object> - Parameters:
key
- AnItem
object- Returns:
- A node validator object
- Throws:
ItemNotFoundException
- If no node loader is found and theuseNullValidatorIfNotFound()
setting is false
-
useNullValidatorIfNotFound
public boolean useNullValidatorIfNotFound()Get the null validator setting.- See Also:
-
setUsNullValidatorIfNotFound
public void setUsNullValidatorIfNotFound(boolean useNullValidator) Set a flag that determines if aNullNodeValidator
should be used or if anItemNotFoundException
should be thrown if no registered node validator is found for a specific key.- Parameters:
useNullValidator
- TRUE to use anNullNodeValidator
, FALSE to throw an exception
-
registerNodeValidator
public void registerNodeValidator(Item key, Class<? extends NodeValidator<? extends BasicItem>> validatorClass) throws NoSuchMethodException, ClassCastException Register a node validator implementation. The implementation must have a public no-argument constructor. The given class is checked withClassUtil.checkAndLoadClass(ClassLoader, String, boolean, Class, Class...)
- Parameters:
key
- The item type the node validator handlesvalidatorClass
- The class name of a class that implementsNodeValidator
, or null to unregister an existig validator- Throws:
NoSuchMethodException
- If the given class has no public no-argument constructorClassCastException
- If the given class doesn't implement theNodeValidator
interface
-
registerCheckedNodeValidator
Register a node loader implementation that you are sure fulfills the requirements. Eg. it must have a public no-argument constructor and implement theNodeValidator
interface.- See Also:
-
registerDefaultNodeValidators
protected void registerDefaultNodeValidators()Registers default item node validators fromBioSource
toExperiment
, etc.
-