org.sapia.validator
Class Status

java.lang.Object
  extended by org.sapia.validator.Status

public class Status
extends Object

Models a validation status. An instance of this class is encapsulated by a ValidationContext. It holds the current validation errors (if any).

From within the Validate method of a Rule, validation errors must be signaled through one of this class' error() methods, as in the following:

 // 'this' is the current Rule instance.
 ...
 public void validate(ValidationContext ctx){
   ctx.getStatus().error(this);
 }
 ...
 

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
Status(ValidationContext ctx)
          Constructor for Status.
 
Method Summary
 void addError(ValidationErr err)
           
 void addErrors(List errs)
           
 void error(Rule r)
          Registers a validation error for the given rule.
 void error(Rule r, String msg)
          Registers an error for the given Rule.
 void error(Rule r, Throwable err)
          Registers an error for the given Rule.
 List getErrors()
          Returns this instance's list of validation errors.
 boolean isError()
          Returns true if this instance contains one or more validation errors.
 List removeAnonymousErrors()
          Returns the validation errors that do not have an ID defined.
 List removeErrors()
          Returns the validation errors that this instance holds.
 List removeErrorsFor(String id)
          Returns the validation errors that this instance holds, and whose identifier starts with the given one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Status

public Status(ValidationContext ctx)
Constructor for Status.

Method Detail

error

public void error(Rule r)
Registers a validation error for the given rule.

Parameters:
r - a Rule.
See Also:
ValidationErr

error

public void error(Rule r,
                  String msg)
Registers an error for the given Rule. Internally creates a ValidationException that is assigned to a ValidationErr that is added to this instance's list of ValidationErrs.

See Also:
ValidationErr

error

public void error(Rule r,
                  Throwable err)
Registers an error for the given Rule. The Throwable instance is is assigned to a ValidationErr that is added to this instance's list of ValidationErrs.

See Also:
ValidationErr

getErrors

public List getErrors()
Returns this instance's list of validation errors.

Returns:
a List of ValidationErr.

isError

public boolean isError()
Returns true if this instance contains one or more validation errors.

Returns:
true if this instance contains one or more validation errors.

addError

public void addError(ValidationErr err)
Parameters:
err - a ValidationErr

addErrors

public void addErrors(List errs)
Parameters:
errs - a List of ValidationErrs.

removeErrorsFor

public List removeErrorsFor(String id)
Returns the validation errors that this instance holds, and whose identifier starts with the given one. The returned error objects are at the same time removed from this instance.

Returns:
a List of ValidationErrs.

removeErrors

public List removeErrors()
Returns the validation errors that this instance holds. The returned error objects are at the same time removed from this instance.

Returns:
a List of ValidationErrs.

removeAnonymousErrors

public List removeAnonymousErrors()
Returns the validation errors that do not have an ID defined. The returned error objects are at the same time removed from this instance.

Returns:
a List of ValidationErrs.


Copyright © 2002 Sapia Open Community, Inc. All Rights Reserved.