public abstract class AbstractValidationRule extends Object implements ValidationRule
ValidationTest
annotation. The tests will
be invoked in they appear within the class.Constructor and Description |
---|
AbstractValidationRule() |
Modifier and Type | Method and Description |
---|---|
boolean |
execute(org.apache.commons.chain.Context theContext)
Invokes the validation tests in the rule in their declared order.
|
String |
getCaption()
Gets a caption describing the rule.
|
protected RuleContext |
getChildContext(URL child)
Gets a rule context for validating a file or directory inside
the current target.
|
protected RuleContext |
getContext()
Gets the rule context.
|
protected ProblemListener |
getListener()
Gets the problem listener for this validation rule.
|
protected String |
getParentTarget()
Gets the parent target location for this rule.
|
protected TargetRegistrar |
getRegistrar()
Gets the target registrar for this validation rule.
|
protected URL |
getTarget()
Gets the target of this rule.
|
abstract boolean |
isApplicable(String location)
Tests whether a rule is applicable to a target location.
|
protected void |
reportError(ProblemDefinition defn,
URL targetUrl,
int lineNumber,
int columnNumber)
Reports an error to the validation listener.
|
protected void |
reportError(ProblemDefinition defn,
URL target,
int lineNumber,
int columnNumber,
String message)
Reports an error to the validation listener with a custom message.
|
void |
setCaption(String caption)
Sets the caption for this chain.
|
public boolean execute(org.apache.commons.chain.Context theContext) throws Exception
ValidationTest
annotation.execute
in interface org.apache.commons.chain.Command
theContext
- the context for the rule, which must be a RuleContext
{@inheritDoc}
Exception
protected RuleContext getContext()
protected RuleContext getChildContext(URL child) throws MalformedURLException, URISyntaxException
child
- the child targetURISyntaxException
MalformedURLException
protected URL getTarget()
protected String getParentTarget()
protected ProblemListener getListener()
protected TargetRegistrar getRegistrar()
protected void reportError(ProblemDefinition defn, URL targetUrl, int lineNumber, int columnNumber)
defn
- the problem definitiontargetFile
- the validation target file containing the problemlineNumber
- the line number, or -1 if no line number appliescolumnNumber
- the column number, or -1 if no column number appliesprotected void reportError(ProblemDefinition defn, URL target, int lineNumber, int columnNumber, String message)
defn
- the problem definitiontarget
- the validation target containing the problemlineNumber
- the line number, or -1 if no line number appliescolumnNumber
- the column number, or -1 if no column number appliesmessage
- the error message to reportpublic abstract boolean isApplicable(String location)
isApplicable
in interface ValidationRule
location
- the target locationpublic final String getCaption()
ValidationRule
getCaption
in interface ValidationRule
public final void setCaption(String caption)
caption
- the new caption stringCopyright © 2010–2017 Planetary Data System. All rights reserved.