org.iscreen.ognl
Class OgnlConfiguredValidator

java.lang.Object
  extended by org.iscreen.impl.BaseConfiguredValidator
      extended by org.iscreen.ognl.OgnlConfiguredValidator
All Implemented Interfaces:
ValidatorWrapper

public class OgnlConfiguredValidator
extends BaseConfiguredValidator

A special validator wrapper that wraps a Validator and the configuration associated with it.

Author:
Shellman, Dan

Field Summary
static java.lang.String DEFAULT_FROM
           
static java.lang.String DEFAULT_TO
           
 
Fields inherited from class org.iscreen.impl.BaseConfiguredValidator
containingService, declared, doc, failFastFlag, id, ifExp, label, mappings, name, parsedDoc, ref, staticProperties, validator, validatorClass
 
Constructor Summary
OgnlConfiguredValidator()
          Default constructor.
 
Method Summary
 void addMapping(java.lang.String from, java.lang.String to)
          Adds a mapping for mapping the object being validated to the beanToValidate object (that the Validator created).
 void addStaticProperty(java.lang.String property, java.lang.Object obj)
          Adds a "static" property to set on the underlying Validator.
protected  java.lang.String convertDoc(java.lang.Object obj, java.lang.String unconvertedDoc)
          Convert the documentation text using the embedded markers.
protected  void executeMappings(java.lang.Object from, java.lang.Object to)
          Maps the appropriate properties from one object to another.
 Validator getConfiguredValidator()
          Creates the Validator and configures it.
protected static OgnlObjectMapping getDefaultMapping()
          Create a default mapping so that if no mapping is defined in configuration, a default mapping can be used.
protected  java.util.Collection getFields()
          Retrieves the Collection of fields (the 'getter' OGNL expressions) that are used in mapping properties from the JavaBean/Object being validated to the validation bean.
protected  boolean shouldExecute(java.lang.Object obj)
          Determines whether this validator should be executed or not.
 
Methods inherited from class org.iscreen.impl.BaseConfiguredValidator
getDoc, getFieldsTrace, getId, getIfExpression, getLabel, getMappings, getName, getRawDoc, getServiceId, getStaticProperties, getValidatorClass, isDeclared, isFailFast, setClassName, setDoc, setFailFast, setId, setIfExpression, setLabel, setLabel, setName, setRef, setValidationService, signalDeclared, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TO

public static final java.lang.String DEFAULT_TO
See Also:
Constant Field Values

DEFAULT_FROM

public static final java.lang.String DEFAULT_FROM
See Also:
Constant Field Values
Constructor Detail

OgnlConfiguredValidator

public OgnlConfiguredValidator()
Default constructor.

Method Detail

executeMappings

protected void executeMappings(java.lang.Object from,
                               java.lang.Object to)
Maps the appropriate properties from one object to another.

Specified by:
executeMappings in class BaseConfiguredValidator
Parameters:
from - The object to map from.
to - The object to map to.

addMapping

public void addMapping(java.lang.String from,
                       java.lang.String to)
Adds a mapping for mapping the object being validated to the beanToValidate object (that the Validator created).

Specified by:
addMapping in class BaseConfiguredValidator
Parameters:
from - The OGNL from expression (getter)
to - The OGNL to expression (setter)

addStaticProperty

public void addStaticProperty(java.lang.String property,
                              java.lang.Object obj)
Adds a "static" property to set on the underlying Validator. A "static" property is really an OGNL expression that will set some value on the Validator once (such as a constraint, service, or failure message).

For failures, the object type should be an OgnlMessage. For a constraint or service, any object type is fine (as long as it maps to the underlying Validator property).

Specified by:
addStaticProperty in class BaseConfiguredValidator
Parameters:
property - The OGNL expression to set a value
obj - The value to set, once, on the Validator to configure it.

getDefaultMapping

protected static OgnlObjectMapping getDefaultMapping()
Create a default mapping so that if no mapping is defined in configuration, a default mapping can be used.

Returns:
Returns a default configured mapping.

getConfiguredValidator

public Validator getConfiguredValidator()
Creates the Validator and configures it. Multiple calls will NOT construct a new Validator each call, but will return the same instance created the first time.

Specified by:
getConfiguredValidator in class BaseConfiguredValidator
Returns:
Returns a created and configured Validator.

getFields

protected java.util.Collection getFields()
Retrieves the Collection of fields (the 'getter' OGNL expressions) that are used in mapping properties from the JavaBean/Object being validated to the validation bean.

Specified by:
getFields in class BaseConfiguredValidator
Returns:
Returns the Collection of fields (the 'getter' OGNL expressions).

convertDoc

protected java.lang.String convertDoc(java.lang.Object obj,
                                      java.lang.String unconvertedDoc)
Description copied from class: BaseConfiguredValidator
Convert the documentation text using the embedded markers.

Specified by:
convertDoc in class BaseConfiguredValidator
Parameters:
obj - The context bean (root) for converting the doc.
unconvertedDoc - The raw documentation text.
Returns:
Returns the converted documentation text.

shouldExecute

protected boolean shouldExecute(java.lang.Object obj)
Description copied from class: BaseConfiguredValidator
Determines whether this validator should be executed or not.

Specified by:
shouldExecute in class BaseConfiguredValidator
Returns:
Returns true if the validator should be executed.