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.apache.cocoon.forms.datatype.validationruleimpl
Class AbstractValidationRule

    java.lang.Object
      org.apache.cocoon.forms.datatype.validationruleimpl.AbstractValidationRule

All Implemented Interfaces:
  ValidationRule

Direct Known Subclasses:
  AssertValidationRule, EmailValidationRule, LengthValidationRule, Mod10ValidationRule, RangeValidationRule, RegExpValidationRule, ValueCountValidationRule

public abstract class AbstractValidationRule
extends Object
implements ValidationRule

Abstract base class providing common functionality for many `ValidationRule` implementations.

Version:
  $Id: AbstractValidationRule.java 587759 2007-10-24 03:00:37Z vgritsenko $

Constructor Summary
`AbstractValidationRule()`

Method Summary
`protected Object` | `evaluateComparable(org.outerj.expression.Expression expression, org.outerj.expression.ExpressionContext expressionContext, String exprName, String ruleName)` Helper method for evaluating expressions whose result is comparable.
`protected Object` | `evaluateNumeric(org.outerj.expression.Expression expression, org.outerj.expression.ExpressionContext expressionContext, String exprName, String ruleName)` Helper method for evaluating expressions whose result is numeric.
`ValidationError` | `getFailMessage()` Returns the failMessage wrapped in a ValidationError object.
`boolean` | `hasFailMessage()` Returns true if this validation rule has a user-defined fail message.
`void` | `setFailMessage(XMLizable object)` Sets the failmessage to use for this validation rule, this will be used instead of the validation rules' built-in message.

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

Methods inherited from interface org.apache.cocoon.forms.datatype.ValidationRule
`supportsType, validate`

Constructor Detail

### AbstractValidationRule

    public AbstractValidationRule()

Method Detail

### setFailMessage

    public void setFailMessage(XMLizable object)

  Sets the failmessage to use for this validation rule, this will be used instead of the validation rules' built-in message. The message itself should be an object impementing XMLizable, such as a SaxBuffer instance. This allows fail messages to contain mixed content (instead of just being a string).

### getFailMessage

    public ValidationError getFailMessage()

  Returns the failMessage wrapped in a ValidationError object.

### hasFailMessage

    public boolean hasFailMessage()

  Returns true if this validation rule has a user-defined fail message.

### evaluateNumeric

    protected Object evaluateNumeric(org.outerj.expression.Expression expression,
                                     org.outerj.expression.ExpressionContext expressionContext,
                                     String exprName,
                                     String ruleName)

  Helper method for evaluating expressions whose result is numeric.

  Parameters:
    `exprName` - a name for the expression that's descriptive for the user, e.g. the name of the attribute in which it was defined
    `ruleName` - a descriptive name for the validation rule, usually the rule's element name
  Returns:
    either a ValidationError (because expression evaluation failed) or a CannotYetResolveWarning (because another, required field referenced in the expression has not yet a value), or a BigDecimal.

### evaluateComparable

    protected Object evaluateComparable(org.outerj.expression.Expression expression,
                                        org.outerj.expression.ExpressionContext expressionContext,
                                        String exprName,
                                        String ruleName)

  Helper method for evaluating expressions whose result is comparable.

  Parameters:
    `exprName` - a name for the expression that's descriptive for the user, e.g. the name of the attribute in which it was defined
    `ruleName` - a descriptive name for the validation rule, usually the rule's element name
  Returns:
    either a ValidationError (because expression evaluation failed) or a CannotYetResolveWarning (because another, required field referenced in the expression has not yet a value), or a BigDecimal.

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

Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.