com.atlassian.plugin.util.validation
Class ValidationPattern

java.lang.Object
  extended by com.atlassian.plugin.util.validation.ValidationPattern

public class ValidationPattern
extends java.lang.Object

Validates a pattern of rules against a dom4j node, patterned off of Schematron

Since:
2.2.0

Nested Class Summary
static class ValidationPattern.Rule
          The rule as a series of tests
static class ValidationPattern.RuleTest
          A test within a rule
 
Method Summary
static ValidationPattern createPattern()
           
 void evaluate(org.dom4j.Node node)
          Evaluates the rules against the provided node
 ValidationPattern rule(java.lang.String context, ValidationPattern.RuleTest... tests)
          Adds a rule to the current pattern
 ValidationPattern rule(ValidationPattern.RuleTest... tests)
          Adds a rule to the current pattern, assuming the current context is "."
static ValidationPattern.RuleTest test(java.lang.String xpath)
          Creates a test using the passed xpath expression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createPattern

public static ValidationPattern createPattern()
Returns:
a new pattern instance

rule

public ValidationPattern rule(java.lang.String context,
                              ValidationPattern.RuleTest... tests)
Adds a rule to the current pattern

Parameters:
context - The xpath expression to determine one or more nodes to evaluate the rules against
tests - A series of tests
Returns:
this for chaining

rule

public ValidationPattern rule(ValidationPattern.RuleTest... tests)
Adds a rule to the current pattern, assuming the current context is "."

Parameters:
tests - A series of tests
Returns:
this for chaining

evaluate

public void evaluate(org.dom4j.Node node)
              throws ValidationException
Evaluates the rules against the provided node

Parameters:
node - The node to evaluate
Throws:
ValidationException - If a validation error occurs. If wanting to resolve i18n keys to messages, you can access the list of errors from the exception.

test

public static ValidationPattern.RuleTest test(java.lang.String xpath)
Creates a test using the passed xpath expression

Parameters:
xpath - The test expression
Returns:
The rule to mutate


Copyright © 2013 Atlassian. All Rights Reserved.