it.eng.spago.validation.fieldvalidators
Class AbstractFieldValidator

java.lang.Object
  extended byit.eng.spago.dispatching.service.DefaultRequestContext
      extended byit.eng.spago.validation.fieldvalidators.AbstractFieldValidator
All Implemented Interfaces:
FieldValidatorIFace, RequestContextIFace, java.io.Serializable
Direct Known Subclasses:
AlphaNumericValidator, DateValidator, EMailValidator, FiscalCodeValidator, GenericFieldValidator, LetterStringValidator, NameValidator, NumericValidator, RegExpValidator, UrlValidator

public abstract class AbstractFieldValidator
extends DefaultRequestContext
implements FieldValidatorIFace

Author:
zoppello An abstract class that implements FieldValidatorIFace, in this class there is the code for handling of the TYPED_SERVICE_REQUEST source bean that will contains the field with alias after the validation
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_VALUE_IDENTIFIER
           
static java.lang.String GENERIC_ERROR_IDENTIFIER
           
static java.lang.String TYPED_SERVICE_REQUEST
          The Key of the element that represent the Typed service Request
 
Constructor Summary
AbstractFieldValidator()
           
 
Method Summary
 SourceBean getConfig()
          The getter method for the configuration of the field Validator
 java.lang.String getErrorCode(java.lang.String errorCodeIdentifier, java.lang.String defaultCode, java.util.Map fieldValidationParams)
          Retrieve the error code from the field configuration or from the validator configuration
 java.lang.String getUserFieldName(java.lang.String fieldName)
          Return the field name used in error messages.
 void init(SourceBean config)
          Initialize The validator with his configuration
 void saveTypedValue(SourceBean serviceRequest, java.lang.String name, java.lang.Object value)
          Save in the Typed Service Request the attribute with name and value Subclasses must use this method to save the field converted with typed value and alias
 void setDefault(SourceBean serviceRequest, java.lang.String fieldName, java.util.Map fieldValidationParams)
           
 
Methods inherited from class it.eng.spago.dispatching.service.DefaultRequestContext
getErrorHandler, getRequestContainer, getResponseContainer, getServiceRequest, getServiceResponse, setRequestContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface it.eng.spago.validation.FieldValidatorIFace
validateField
 

Field Detail

TYPED_SERVICE_REQUEST

public static final java.lang.String TYPED_SERVICE_REQUEST
The Key of the element that represent the Typed service Request

See Also:
Constant Field Values

GENERIC_ERROR_IDENTIFIER

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

DEFAULT_VALUE_IDENTIFIER

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

AbstractFieldValidator

public AbstractFieldValidator()
Method Detail

saveTypedValue

public void saveTypedValue(SourceBean serviceRequest,
                           java.lang.String name,
                           java.lang.Object value)
Save in the Typed Service Request the attribute with name and value Subclasses must use this method to save the field converted with typed value and alias

Parameters:
serviceRequest - The Spago Service Request
name - The name of the attribute to store
value - The value to store

getConfig

public SourceBean getConfig()
The getter method for the configuration of the field Validator

Specified by:
getConfig in interface FieldValidatorIFace
See Also:
FieldValidatorIFace.getConfig()

init

public void init(SourceBean config)
Initialize The validator with his configuration

Specified by:
init in interface FieldValidatorIFace
See Also:
FieldValidatorIFace.init(it.eng.spago.base.SourceBean)

getErrorCode

public java.lang.String getErrorCode(java.lang.String errorCodeIdentifier,
                                     java.lang.String defaultCode,
                                     java.util.Map fieldValidationParams)
Retrieve the error code from the field configuration or from the validator configuration

Returns:
The error code for this validator.

getUserFieldName

public java.lang.String getUserFieldName(java.lang.String fieldName)
Return the field name used in error messages.

Parameters:
fieldName - Name of the field in the form.
Returns:
Field name used in error messages.

setDefault

public void setDefault(SourceBean serviceRequest,
                       java.lang.String fieldName,
                       java.util.Map fieldValidationParams)
                throws EMFValidationError
Specified by:
setDefault in interface FieldValidatorIFace
Throws:
EMFValidationError