Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.providers.datadefinition.makumba.validation
Class ComparisonValidationRule

    java.lang.Object
      org.makumba.providers.datadefinition.makumba.validation.BasicValidationRule
          org.makumba.providers.datadefinition.makumba.validation.ComparisonValidationRule

All Implemented Interfaces:
  Serializable, Comparable<ValidationRule>, ValidationRule

    public class ComparisonValidationRule

extends BasicValidationRule

This validation rule implements comparison validations between two fields, using the syntax <fieldname> comparison operator <otherFieldname>. Valid operators are "(<|>|=|>=|<=|!=)". This rule can be used for either two date, number or string types.

Version:
  $Id: NumberRangeValidationRule.java,v 1.1 Sep 6, 2007 1:31:27 AM rudi Exp $
Author:
  Rudolf Mayer
See Also:
  Serialized Form

Field Summary
`static String` | `compareTo` The compare-to part, either another field, or a date fucntion:
`static String` | `comparisonOperators` Possible comparison operators: "(<|>|=|>=|<=|!=)"
`static String` | `dateExpression`
`static String` | `dateFunction`
`static String` | `dateFunctionExpression` the full date function "date\\(([\\s]*(\\$now[\\s]*(\\+[\\s]*\\d+|-[\\s]*\\d+)?|\\d+)[\\s]*,){0,5}([\\s]*(\\$now[\\s]*(\\+[\\s]*\\d+|-[\\s]*\\d+)?|\\d+)[\\s]*)?\\)".
`static String` | `dateFunctionParamExpression`
`static String` | `now`
`static String` | `rule`
`static String` | `today`

Fields inherited from class org.makumba.providers.datadefinition.makumba.validation.BasicValidationRule
`allowedTypes, errorMessage, fd, fieldDef, fieldFunction, fieldName, lowerFunction, NUMBER_TYPES, operators, rangeDef, rangeValue, ruleName, ruleSyntax, STRING_TYPES, upperFunction`

Constructor Summary
`ComparisonValidationRule(FieldDefinition fd, String fieldName, String functionName, FieldDefinition otherFd, String otherFieldName, String ruleName, String errorMessage, String compareOperator)`
`ComparisonValidationRule(FieldDefinition fd, String fieldName, String compareToExpression, String ruleName, String errorMessage, String compareOperator)`

Method Summary
`Date` | `evaluateExpression()`
`String` | `getCompareOperator()`
`static Matcher` | `getDateExpressionMatcher(String rule)`
`String` | `getFunctionName()`
`static Matcher` | `getMatcher(String rule)`
`static String` | `getOperator()`
`static List<String>` | `getOperators()`
`FieldDefinition` | `getOtherFd()`
`String` | `getOtherFieldName()`
`boolean` | `isCompareToExpression()`
`static void` | `main(String[] args)` Do some pattern matching tests.
`static boolean` | `matches(String rule)`
`static boolean` | `matchesDateExpression(String rule)`
`protected boolean` | `throwException(boolean b)`
`String` | `toString()`
`boolean` | `validate(Object value)` Perform the validation process.

Methods inherited from class org.makumba.providers.datadefinition.makumba.validation.BasicValidationRule
`applyFunction, compareTo, extractFunctionArgument, extractFunctionNameFromStatement, getAllowedTypes, getErrorMessage, getFieldDefinition, getFieldName, getRuleName, getValidationRuleOperators, isFunctionCall, isValidFunctionCall`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### now

    public static final String now

See Also:
  Constant Field Values

### today

    public static final String today

See Also:
  Constant Field Values

### dateFunction

    public static final String dateFunction

See Also:
  Constant Field Values

### dateFunctionParamExpression

    public static final String dateFunctionParamExpression

See Also:
  Constant Field Values

### dateFunctionExpression

    public static final String dateFunctionExpression

  the full date function "date\\(([\\s]*(\\$now[\\s]*(\\+[\\s]*\\d+|-[\\s]*\\d+)?|\\d+)[\\s]*,){0,5}([\\s]*(\\$now[\\s]*(\\+[\\s]*\\d+|-[\\s]*\\d+)?|\\d+)[\\s]*)?\\)".

  See Also:
    Constant Field Values

### compareTo

    public static final String compareTo

  The compare-to part, either another field, or a date fucntion:

### dateExpression

    public static final String dateExpression

### comparisonOperators

    public static final String comparisonOperators

  Possible comparison operators: "(<|>|=|>=|<=|!=)"

  See Also:
    Constant Field Values

### rule

    public static final String rule

Constructor Detail

### ComparisonValidationRule

    public ComparisonValidationRule(FieldDefinition fd,
                                    String fieldName,
                                    String functionName,
                                    FieldDefinition otherFd,
                                    String otherFieldName,
                                    String ruleName,
                                    String errorMessage,
                                    String compareOperator)
                             throws ValidationDefinitionParseError

Throws:
  `ValidationDefinitionParseError`

### ComparisonValidationRule

    public ComparisonValidationRule(FieldDefinition fd,
                                    String fieldName,
                                    String compareToExpression,
                                    String ruleName,
                                    String errorMessage,
                                    String compareOperator)

Method Detail

### validate

    public boolean validate(Object value)
                     throws InvalidValueException

  Description copied from interface: `ValidationRule`
  Perform the validation process.

  Throws:
    `InvalidValueException` - if the validation fails

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### getOtherFieldName

    public String getOtherFieldName()

### getOtherFd

    public FieldDefinition getOtherFd()

### getCompareOperator

    public String getCompareOperator()

### getFunctionName

    public String getFunctionName()

### throwException

    protected boolean throwException(boolean b)
                              throws InvalidValueException

  Throws:
    `InvalidValueException`

### isCompareToExpression

    public boolean isCompareToExpression()

### evaluateExpression

    public Date evaluateExpression()
                            throws ValidationDefinitionParseError

  Throws:
    `ValidationDefinitionParseError`

### matches

    public static boolean matches(String rule)

### getMatcher

    public static Matcher getMatcher(String rule)

### getDateExpressionMatcher

    public static Matcher getDateExpressionMatcher(String rule)

### matchesDateExpression

    public static boolean matchesDateExpression(String rule)

### getOperators

    public static List<String> getOperators()

### main

    public static void main(String[] args)

  Do some pattern matching tests.

### getOperator

    public static String getOperator()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20