Class AbstractValidationRule

    • Constructor Detail

      • AbstractValidationRule

        public AbstractValidationRule()
    • Method Detail

      • execute

        public boolean execute​(org.apache.commons.chain.Context theContext)
                        throws Exception
        Invokes the validation tests in the rule in their declared order. Validation tests are denoted by public methods annotated with the ValidationTest annotation.
        Specified by:
        execute in interface org.apache.commons.chain.Command
        Parameters:
        theContext - the context for the rule, which must be a RuleContext
        Throws:
        Exception
      • getContext

        protected RuleContext getContext()
        Gets the rule context.
        Returns:
        the context
      • getTarget

        protected URL getTarget()
        Gets the target of this rule.
        Returns:
        the validation target
      • getParentTarget

        protected String getParentTarget()
        Gets the parent target location for this rule.
        Returns:
        the parent target location, or null if no parent
      • getListener

        protected ProblemListener getListener()
        Gets the problem listener for this validation rule.
        Returns:
        the problem listener
      • getRegistrar

        protected TargetRegistrar getRegistrar()
        Gets the target registrar for this validation rule.
        Returns:
        the target registrar
      • reportError

        protected void reportError​(ProblemDefinition defn,
                                   URL targetUrl,
                                   int lineNumber,
                                   int columnNumber)
        Reports an error to the validation listener.
        Parameters:
        defn - the problem definition
        targetFile - the validation target file containing the problem
        lineNumber - the line number, or -1 if no line number applies
        columnNumber - the column number, or -1 if no column number applies
      • reportError

        protected void reportError​(ProblemDefinition defn,
                                   URL target,
                                   int lineNumber,
                                   int columnNumber,
                                   String message)
        Reports an error to the validation listener with a custom message.
        Parameters:
        defn - the problem definition
        target - the validation target containing the problem
        lineNumber - the line number, or -1 if no line number applies
        columnNumber - the column number, or -1 if no column number applies
        message - the error message to report
      • isApplicable

        public abstract boolean isApplicable​(String location)
        Tests whether a rule is applicable to a target location.
        Specified by:
        isApplicable in interface ValidationRule
        Parameters:
        location - the target location
        Returns:
        true, if the rule is applicable to the target, false otherwise
      • setCaption

        public final void setCaption​(String caption)
        Sets the caption for this chain.
        Parameters:
        caption - the new caption string
      • isInfoLogLevel

        protected boolean isInfoLogLevel()
      • isDebugLogLevel

        protected boolean isDebugLogLevel()