org.formaria.pojo.commons
Class PojoCommonsValidator

java.lang.Object
  extended by org.formaria.aria.validation.AbstractValidator
      extended by org.formaria.pojo.commons.PojoCommonsValidator
All Implemented Interfaces:
Validator
Direct Known Subclasses:
PojoCommonsFieldValidator

public class PojoCommonsValidator
extends AbstractValidator

A validtor for validation of pojo field values

Copyright (c) Formaria Ltd., 2008

License: see license.txt


Field Summary
protected  java.lang.String dataPath
           
protected  java.lang.String formName
           
protected  DataModel pojo
           
protected  java.lang.Object pojoObject
           
 
Fields inherited from class org.formaria.aria.validation.AbstractValidator
container, currentProject, errorLevel, formattedMessage, mandatory, mask, message, showErrorBadges, start, translator, USE_FAIL_STYLE, USE_NORMAL_STYLE, USE_WARN_STYLE, validationMethod, validationName, value
 
Fields inherited from interface org.formaria.aria.validation.Validator
IGNORE_BLANKS, LEVEL_ERROR, LEVEL_IGNORE, LEVEL_WARNING, MANDATORY, STRICT_CHECK, WEAK_CHECK
 
Constructor Summary
PojoCommonsValidator(Project project)
          Create a new POJO validator
 
Method Summary
protected  boolean applyErrorStyle(javax.swing.JComponent comp, java.lang.String propertyName, int level)
          Apply the error style to the component with the matching property value
protected  java.lang.Object doCommonsValidation(java.lang.Object c, java.lang.String fieldName)
           
 java.lang.String getMessage()
          Get the validation message which is formatted after the tokens have been replaced
protected  void getPojo()
          Lookup the pojo
 void setup(XmlElement ruleConfig, XmlElement instanceConfig)
          Set the validation parameters
 void validate(java.lang.Object c, boolean forceMandatory)
          Carry out a page level or inline validation on the passed component
 int validateAllProperties(javax.swing.JComponent comp)
           
 int validateProperties(javax.swing.JComponent comp, boolean forceMandatory)
           
 
Methods inherited from class org.formaria.aria.validation.AbstractValidator
applyErrorStyle, getLevel, getMask, getName, getText, getValueAsString, invokeMethod, replaceToken, replaceTokens, setMask, setName, setValidationColors, setValidationMethod, throwException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pojo

protected DataModel pojo

pojoObject

protected java.lang.Object pojoObject

dataPath

protected java.lang.String dataPath

formName

protected java.lang.String formName
Constructor Detail

PojoCommonsValidator

public PojoCommonsValidator(Project project)
Create a new POJO validator

Parameters:
project - the owner project
Method Detail

validate

public void validate(java.lang.Object c,
                     boolean forceMandatory)
              throws java.lang.Exception
Description copied from interface: Validator
Carry out a page level or inline validation on the passed component

Parameters:
c - The component whose value is to be validated
forceMandatory - Set to true if page level validations are taking place or false for inline
Throws:
java.lang.Exception - throw if there is a problem

validateProperties

public int validateProperties(javax.swing.JComponent comp,
                              boolean forceMandatory)
                       throws java.lang.Exception
Throws:
java.lang.Exception

validateAllProperties

public int validateAllProperties(javax.swing.JComponent comp)
                          throws java.lang.Exception
Throws:
java.lang.Exception

doCommonsValidation

protected java.lang.Object doCommonsValidation(java.lang.Object c,
                                               java.lang.String fieldName)

setup

public void setup(XmlElement ruleConfig,
                  XmlElement instanceConfig)
Set the validation parameters

Specified by:
setup in interface Validator
Overrides:
setup in class AbstractValidator
Parameters:
ruleConfig - the validator parameters as declared in the validations rules file
instanceConfig - the validator instance parameters as declared in the page file

getMessage

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

Specified by:
getMessage in interface Validator
Overrides:
getMessage in class AbstractValidator
Returns:
The formatted message.

getPojo

protected void getPojo()
Lookup the pojo


applyErrorStyle

protected boolean applyErrorStyle(javax.swing.JComponent comp,
                                  java.lang.String propertyName,
                                  int level)
Apply the error style to the component with the matching property value

Parameters:
comp -
propertyName -
level -
Returns: