org.formproc.validation
Class RuleResult

java.lang.Object
  |
  +--org.formproc.validation.RuleResult

public class RuleResult
extends java.lang.Object

The RuleResult class encapsulates a result of a validation against a Rule. Clients can use the isValid() method to determine if the value was validated against the rule.

Author:
Anthony Eden

Constructor Summary
RuleResult()
          Construct a new RuleResult with valid set to true.
RuleResult(java.lang.String errorMessage)
          Construct a new RuleResult with valid set to false and with the given error message.
RuleResult(java.lang.Throwable error)
          Construct a new RuleResult with valid set to false and with the given Throwable error.
RuleResult(java.lang.Throwable error, java.lang.String errorMessage)
          Construct a new RuleResult with valid set to false and with the given Throwable error and error message.
 
Method Summary
 java.lang.Throwable getError()
          Get the error thrown by the rule.
 java.lang.String getErrorMessage()
          Get the error message.
 boolean isValid()
          Return true if the value is valid against the target rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleResult

public RuleResult()
Construct a new RuleResult with valid set to true.


RuleResult

public RuleResult(java.lang.String errorMessage)
Construct a new RuleResult with valid set to false and with the given error message.

Parameters:
errorMessage - An error message

RuleResult

public RuleResult(java.lang.Throwable error)
Construct a new RuleResult with valid set to false and with the given Throwable error. The Throwable's error message will be used as the RuleResult error message.

Parameters:
error - A Throwable

RuleResult

public RuleResult(java.lang.Throwable error,
                  java.lang.String errorMessage)
Construct a new RuleResult with valid set to false and with the given Throwable error and error message.

Parameters:
error - A Throwable
errorMessage - The error message
Method Detail

isValid

public boolean isValid()
Return true if the value is valid against the target rule.

Returns:
True if the value is valid

getErrorMessage

public java.lang.String getErrorMessage()
Get the error message. This method may return null if the rule passed.

Returns:
The error message

getError

public java.lang.Throwable getError()
Get the error thrown by the rule. This method may return null if the rule passed.

Returns:
The error


Copyright (c) 2001-2003 Anthony Eden. All Rights Reserved.