org.sapia.validator
Class Rule

java.lang.Object
  extended by org.sapia.validator.Rule
All Implemented Interfaces:
org.sapia.util.xml.confix.ObjectCreationCallback, Validatable
Direct Known Subclasses:
BeanRule, CompositeRule, GroovyRule, IfDefined, PositiveRule, Select

public abstract class Rule
extends Object
implements Validatable, org.sapia.util.xml.confix.ObjectCreationCallback

This class models a validation rule.

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
Rule()
          Constructor for Rule.
 
Method Summary
 ErrorMessage createMessage()
          Adds an error message to this instance and returns it.
 String getErrorMessageFor(Locale loc)
          Returns the error message corresponding to the given Locale.
 ErrorMessages getErrorMessages()
           
 String getId()
          Returns this instance's unique identifier.
 void initName(String prefix, String localName)
          Inits rule with the specified information.
protected  String localName()
          Returns the local name of this rule.
 Object onCreate()
           
protected  String prefix()
          Returns the prefix of the namespace to which this rule belongs.
protected  String qualifiedName()
          Returns this rule's qualified name (prefix() + ':' + localName()).
 void setErrorMessages(ErrorMessages msgs)
          Sets this instance's error messages.
 void setId(String id)
           
abstract  void validate(ValidationContext context)
          Validates this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule()
Constructor for Rule.

Method Detail

initName

public void initName(String prefix,
                     String localName)
Inits rule with the specified information.

Parameters:
this - rule's namespace prefix.
this - rule's local name.

setId

public void setId(String id)
See Also:
getId()

getId

public String getId()
Description copied from interface: Validatable
Returns this instance's unique identifier.

Specified by:
getId in interface Validatable
Returns:
a unique identifier.
See Also:
Validatable.getId()

createMessage

public ErrorMessage createMessage()
Adds an error message to this instance and returns it.

Returns:
the created ErrorMessage.

setErrorMessages

public void setErrorMessages(ErrorMessages msgs)
Sets this instance's error messages.

Parameters:
msgs - some ErrorMessages.

getErrorMessages

public ErrorMessages getErrorMessages()
Returns:
this instance's ErrorMessages.

getErrorMessageFor

public String getErrorMessageFor(Locale loc)
Returns the error message corresponding to the given Locale.

Parameters:
a - Locale.
Returns:
an error message, or null if no error message could be found for the given Locale.

validate

public abstract void validate(ValidationContext context)
Description copied from interface: Validatable
Validates this instance.

Specified by:
validate in interface Validatable
See Also:
Validatable.validate(ValidationContext)

localName

protected String localName()
Returns the local name of this rule.

Returns:
this instance's local name.

prefix

protected String prefix()
Returns the prefix of the namespace to which this rule belongs.

Returns:
this instance's namespace prefix.

qualifiedName

protected String qualifiedName()
Returns this rule's qualified name (prefix() + ':' + localName()).

Returns:
the qualified name of this rule.
See Also:
prefix(), localName()

onCreate

public Object onCreate()
                throws org.sapia.util.xml.confix.ConfigurationException
Specified by:
onCreate in interface org.sapia.util.xml.confix.ObjectCreationCallback
Throws:
org.sapia.util.xml.confix.ConfigurationException


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