public class BasicItemNodeValidatorFactory extends java.lang.Object implements NodeValidatorFactory<BasicItem,java.lang.Object>
BasicItem
node validators.
The key used in createNodeValidator(Object)
should normally be
an Item
object.Modifier and Type | Field and Description |
---|---|
private boolean |
disabled |
private boolean |
useNullValidator |
private java.util.Map<java.lang.Object,java.lang.Class<? extends NodeValidator<? extends BasicItem>>> |
validators |
Constructor and Description |
---|
BasicItemNodeValidatorFactory()
Creates a new factory.
|
Modifier and Type | Method and Description |
---|---|
NodeValidator<? extends BasicItem> |
createNodeValidator(java.lang.Object key)
Create a new node validator that can validate nodes with items of
the specified item type.
|
boolean |
isDisabled()
Check if node validation has been disabled.
|
protected void |
registerCheckedNodeValidator(java.lang.Object key,
java.lang.Class<? extends NodeValidator<? extends BasicItem>> validatorClass)
Register a node loader implementation that you are sure fulfills the
requirements.
|
protected void |
registerDefaultNodeValidators()
Registers default item node validators from
BioSource
to Experiment , etc. |
void |
registerNodeValidator(Item key,
java.lang.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 a
NullNodeValidator should be used
or if an ItemNotFoundException should be thrown
if no registered node validator is found for a specific key. |
boolean |
useNullValidatorIfNotFound()
Get the null validator setting.
|
private final java.util.Map<java.lang.Object,java.lang.Class<? extends NodeValidator<? extends BasicItem>>> validators
private boolean useNullValidator
private boolean disabled
public BasicItemNodeValidatorFactory()
public boolean isDisabled()
NodeValidatorFactory
isDisabled
in interface NodeValidatorFactory<BasicItem,java.lang.Object>
public void setDisabled(boolean disabled)
NodeValidatorFactory
NodeValidatorFactory.createNodeValidator(Object)
should return null or a NullNodeValidator
for all
requests.setDisabled
in interface NodeValidatorFactory<BasicItem,java.lang.Object>
disabled
- TRUE to disable node validationpublic NodeValidator<? extends BasicItem> createNodeValidator(java.lang.Object key)
NullNodeValidator
is returned or an exception
is thrown depending on the useNullValidatorIfNotFound()
option.createNodeValidator
in interface NodeValidatorFactory<BasicItem,java.lang.Object>
key
- An Item
objectItemNotFoundException
- If no node loader is found and the
useNullValidatorIfNotFound()
setting is falsepublic boolean useNullValidatorIfNotFound()
public void setUsNullValidatorIfNotFound(boolean useNullValidator)
NullNodeValidator
should be used
or if an ItemNotFoundException
should be thrown
if no registered node validator is found for a specific key.useNullValidator
- TRUE to use an NullNodeValidator
, FALSE to throw
an exceptionpublic void registerNodeValidator(Item key, java.lang.Class<? extends NodeValidator<? extends BasicItem>> validatorClass) throws java.lang.NoSuchMethodException, java.lang.ClassCastException
ClassUtil.checkAndLoadClass(ClassLoader, String, boolean, Class...)
key
- The item type the node validator handlesvalidatorClass
- The class name of a class that implements NodeValidator
,
or null to unregister an existig validatorjava.lang.NoSuchMethodException
- If the given class has no public no-argument
constructorjava.lang.ClassCastException
- If the given class doesn't implement the
NodeValidator
interfaceprotected void registerCheckedNodeValidator(java.lang.Object key, java.lang.Class<? extends NodeValidator<? extends BasicItem>> validatorClass)
NodeValidator
interface.registerNodeValidator(Item, Class)
protected void registerDefaultNodeValidators()
BioSource
to Experiment
, etc.