net.xoetrope.xui.validation
Class XBaseValidator

java.lang.Object
  extended by net.xoetrope.xui.validation.XBaseValidator
All Implemented Interfaces:
XValidator
Direct Known Subclasses:
XMandatoryValidator, XMinMaxValidator

public abstract class XBaseValidator
extends java.lang.Object
implements XValidator

A basic implementation of the XValidator interface

Copyright: Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt

$Revision: 2.6 $


Field Summary
protected  java.lang.Object container
          Container to be used for validation methods
protected  int errorLevel
          The level of the errors detected by the validation
protected  java.lang.String formattedMessage
          The formatted message
protected  boolean mandatory
          boolean indicating whether component requires input
protected  int mask
          The event mask of the validation
protected  java.lang.String message
          The unformatted message to be displayed
protected  boolean start
          Indicates that the validation has started
protected  java.lang.reflect.Method validationMethod
          Method to be used for callback validations
protected  java.lang.String validationName
          The name of the validation which is being handled by this validator
protected  java.lang.String value
          Used to store the current value contained in the component
 
Fields inherited from interface net.xoetrope.xui.validation.XValidator
IGNORE_BLANKS, LEVEL_ERROR, LEVEL_IGNORE, LEVEL_WARNING, MANDATORY, STRICT_CHECK, WEAK_CHECK
 
Constructor Summary
XBaseValidator()
          null ctor
XBaseValidator(java.lang.String name, int validatorMask)
          Constructor sets up member variables
 
Method Summary
 int getLevel()
          Get the error level of the validations
 int getMask()
          Get the event mask.
 java.lang.String getMessage()
          Get the validation message which is formatted after the tokens have been replaced
 java.lang.String getName()
          Get the name of the validation
protected  java.lang.String getText(java.lang.Object c)
          Get the text value of the component.
 java.lang.String getValueAsString()
          Get the value as a string object
 java.lang.Object invokeMethod()
          Call the funcion to get the value we are validating.
protected  void replaceToken(java.lang.String lookup, java.lang.String replacement)
          Carry out a replacement on the validation message
protected  void replaceTokens()
          Replace any further tokens in the message
 void setMask(int newMask)
          Set the event mask.
 void setName(java.lang.String name)
          Set the name of the validation
 void setup(XmlElement element)
          Set the validation parameters
 void setValidationMethod(java.lang.reflect.Method m, java.lang.Object c)
          Set the Method of the XPage to be invoked when we are doing a funcion validation
protected  void throwException()
          Replace the remaining tokens and throw the exception
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.xoetrope.xui.validation.XValidator
validate
 

Field Detail

mandatory

protected boolean mandatory
boolean indicating whether component requires input


message

protected java.lang.String message
The unformatted message to be displayed


value

protected java.lang.String value
Used to store the current value contained in the component


formattedMessage

protected java.lang.String formattedMessage
The formatted message


validationName

protected java.lang.String validationName
The name of the validation which is being handled by this validator


container

protected java.lang.Object container
Container to be used for validation methods


validationMethod

protected java.lang.reflect.Method validationMethod
Method to be used for callback validations


mask

protected int mask
The event mask of the validation


errorLevel

protected int errorLevel
The level of the errors detected by the validation


start

protected boolean start
Indicates that the validation has started

Constructor Detail

XBaseValidator

public XBaseValidator()
null ctor


XBaseValidator

public XBaseValidator(java.lang.String name,
                      int validatorMask)
Constructor sets up member variables

Parameters:
name - The name of the validation being used by this validator
validatorMask - The event mask of the validation.
Method Detail

getMask

public int getMask()
Get the event mask. The mask helps filter the events for which the validator is invoked

Specified by:
getMask in interface XValidator
Returns:
the mask

setMask

public void setMask(int newMask)
Set the event mask. The mask helps filter the events for which the validator is invoked

Parameters:
newMask - The new mask which is to be used by the validator

setValidationMethod

public void setValidationMethod(java.lang.reflect.Method m,
                                java.lang.Object c)
Set the Method of the XPage to be invoked when we are doing a funcion validation

Specified by:
setValidationMethod in interface XValidator
Parameters:
c - The component being validated
m - The method to be invoked

getName

public java.lang.String getName()
Get the name of the validation

Specified by:
getName in interface XValidator
Returns:
The name

setName

public void setName(java.lang.String name)
Set the name of the validation

Parameters:
name - the new name

getMessage

public java.lang.String getMessage()
Get the validation message which is formatted after the tokens have been replaced

Specified by:
getMessage in interface XValidator
Returns:
The formatted message.

setup

public void setup(XmlElement element)
Set the validation parameters

Parameters:
element - the validator parameters

getValueAsString

public java.lang.String getValueAsString()
Get the value as a string object

Specified by:
getValueAsString in interface XValidator
Returns:
the value as string

getLevel

public int getLevel()
Get the error level of the validations

Specified by:
getLevel in interface XValidator
Returns:
the error level

invokeMethod

public java.lang.Object invokeMethod()
Call the funcion to get the value we are validating.

Returns:
The result of the function call

replaceToken

protected void replaceToken(java.lang.String lookup,
                            java.lang.String replacement)
Carry out a replacement on the validation message

Parameters:
lookup - The text to find
replacement - The text to replace the text with

replaceTokens

protected void replaceTokens()
Replace any further tokens in the message


getText

protected java.lang.String getText(java.lang.Object c)
Get the text value of the component.

Parameters:
c - The component
Returns:
The text components value

throwException

protected void throwException()
                       throws java.lang.Exception
Replace the remaining tokens and throw the exception

Throws:
java.lang.Exception - Throw an exception so that it can be caught