|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sapia.validator.Vlad
public class Vlad
An instance of this class encapsulates rule sets and rules. An instance of this class is used as such:
Vlad v = new Vlad()
.loadDefs("someRuleDefs.xml")
.loadDefs("someOtherRuleDefs.xml")
.load("someRuleSets.xml")
.load("someOtherRuleSets.xml");
RuleSet,
Rule| Field Summary | |
|---|---|
static String |
VLAD_RULES_XML
|
| Constructor Summary | |
|---|---|
Vlad()
Constructor for RuleConfig. |
|
| Method Summary | |
|---|---|
void |
add(Rule rule)
Adds a rule to this instance. |
void |
addGlobal(String name,
Object value)
Adds a global object to this instance. |
void |
addGlobals(Map values)
|
void |
addNamespace(Namespace ns)
Adds the given namespace to this instance. |
void |
addRuleSet(RuleSet set)
Adds a rule set to this instance. |
Object |
getGlobal(String name)
|
Map |
getGlobals()
|
Rule |
getRule(String id)
Returns the rule corresponding to the given ID. |
RuleSet |
getRuleSet(String id)
Returns the rule set corresponding to the given identifier. |
void |
handleObject(String name,
Object ruleOrRuleSet)
|
Vlad |
load(File f)
Loads a ruleset definition corresponding to the given file. |
Vlad |
load(InputStream is)
Loads a ruleset definition corresponding to the given stream. |
Vlad |
load(String resource)
Loads a ruleset definition file as a resource. |
Vlad |
loadDefs(File f)
Loads a rule definition corresponding to the given file. |
Vlad |
loadDefs(InputStream is)
Loads a rule definition corresponding to the given stream. |
Vlad |
loadDefs(String resource)
Loads a rule definition file as a resource. |
Status |
validate(String ruleSetId,
Object obj,
Locale locale)
Validates the given object, using the ruleset whose identifier is given, for the given Locale. |
Status |
validate(String ruleSetId,
Object obj,
Locale locale,
Map contextMap)
Validates the given object, using the ruleset whose identifier is given, for the given Locale. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String VLAD_RULES_XML
| Constructor Detail |
|---|
public Vlad()
| Method Detail |
|---|
public void addGlobal(String name,
Object value)
validate method of this instance is called).
Use of this method should be done prior to using this instance for validation, at initialization time.
name - the name under which the given value should be kept.value - an Object.ValidationContextpublic void addGlobals(Map values)
values - a Map of values to add to this instance's
global values.public Object getGlobal(String name)
name - the name of an expected global value.
Object corresponding to the given name.public Map getGlobals()
Map corresponding to the global values
that this instance holds.public void addRuleSet(RuleSet set)
set - a RuleSet.
public RuleSet getRuleSet(String id)
throws IllegalArgumentException
id - the identifier of the desired RuleSet.
RuleSet.
IllegalArgumentException - if no rule set was found for
the given identifier.public void add(Rule rule)
a - Rule.public void addNamespace(Namespace ns)
ns - a Namespace.
public Rule getRule(String id)
throws IllegalArgumentException
id - the identifier of the desired Rule.
Rule.
IllegalArgumentException - if no rule was found for the given
identifier.
public Status validate(String ruleSetId,
Object obj,
Locale locale)
Locale. The latter is used
to select the proper error messages (in the language that closest
match the given Locale).
ruleSetId - the identifier of a RuleSet.obj - an object to validate.locale - a Locale.
Status.
public Status validate(String ruleSetId,
Object obj,
Locale locale,
Map contextMap)
Locale. The latter is used
to select the proper error messages (in the language that closest
matches the given Locale).
ruleSetId - the identifier of a RuleSet.obj - an object to validate.locale - a Locale.contextMap - a Map with additional context objects which can be acquired
from validation code.
Status.
public Vlad load(String resource)
throws IOException,
ConfigException
resource - the name of a resource.
IOException - if an IO error occurs while loading the resource, or
if no resource exists for the given name.
ConfigException - if a problem occurs while initializing this
instance with the given resource's content.
public Vlad load(File f)
throws IOException,
ConfigException
f - a File
IOException - if an IO error occurs while loading the file.
ConfigException - if a problem occurs while initializing this
instance with the given file's content.
public Vlad load(InputStream is)
throws IOException,
ConfigException
is - an InputStream
IOException - if an IO error occurs while loading the configuration stream.
ConfigException - if a problem occurs while initializing this
instance with the given stream's content.
public Vlad loadDefs(File f)
throws IOException,
ConfigException
f - a File
IOException - if an IO error occurs while loading the file.
ConfigException - if a problem occurs while initializing this
instance with the given file's content.
public Vlad loadDefs(String resource)
throws IOException,
ConfigException
resource - the name of a resource.
IOException - if an IO error occurs while loading the resource, or
if no resource exists for the given name.
ConfigException - if a problem occurs while initializing this
instance with the given resource's content.
public Vlad loadDefs(InputStream is)
throws IOException,
ConfigException
is - an InputStream
IOException - if an IO error occurs while loading the configuration stream.
ConfigException - if a problem occurs while initializing this
instance with the given stream's content.
public void handleObject(String name,
Object ruleOrRuleSet)
throws org.sapia.util.xml.confix.ConfigurationException
handleObject in interface org.sapia.util.xml.confix.ObjectHandlerIForg.sapia.util.xml.confix.ConfigurationExceptionObjectHandlerIF.handleObject(String, Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||