public class ClassValidator extends Object implements Validator
ClassValidator
validates the string argument
values are class names.
The following example shows how to validate the 'logger'
argument value is a class name, that can be instantiated.
... ClassValidator validator = new ClassValidator(); validator.setInstance(true); ArgumentBuilder builder = new ArgumentBuilder(); Argument logger = builder.withName("logger"); .withValidator(validator);
Constructor and Description |
---|
ClassValidator() |
Modifier and Type | Method and Description |
---|---|
ClassLoader |
getClassLoader()
Returns the
ClassLoader used to resolve and load
the classes specified by the argument values. |
boolean |
isInstance()
Returns whether the argument value must represent a
class that can be instantiated.
|
boolean |
isLoadable()
Returns whether the argument value must represent a
class that is loadable.
|
protected boolean |
isPotentialClassName(String name)
Returns whether the specified name is allowed as
a Java class name.
|
void |
setClassLoader(ClassLoader loader)
Specifies the
ClassLoader used to resolve and load
the classes specified by the argument values. |
void |
setInstance(boolean instance)
Specifies whether the argument value must represent a
class that can be instantiated.
|
void |
setLoadable(boolean loadable)
Specifies whether the argument value must represent a
class that is loadable.
|
void |
validate(List values)
Validate each argument value in the specified List against this instances
permitted attributes.
|
public ClassValidator()
public void validate(List values) throws InvalidArgumentException
String
value in the list is
replaced with it's Class
value or instance.validate
in interface Validator
values
- The values to validate.InvalidArgumentException
- If any of the
specified values are not valid.Validator.validate(java.util.List)
public boolean isLoadable()
public void setLoadable(boolean loadable)
loadable
- whether the argument value must
represent a class that is loadable.public ClassLoader getClassLoader()
ClassLoader
used to resolve and load
the classes specified by the argument values.ClassLoader
used to resolve and load
the classes specified by the argument values.public void setClassLoader(ClassLoader loader)
ClassLoader
used to resolve and load
the classes specified by the argument values.loader
- the ClassLoader
used to resolve and load
the classes specified by the argument values.public boolean isInstance()
public void setInstance(boolean instance)
instance
- whether the argument value must
represent a class that can be instantiated.protected boolean isPotentialClassName(String name)
name
- the name to be checkedCopyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.