com.acsinet_solutions.cetia4.controller.map
Class AbstractMapping

java.lang.Object
  extended by com.acsinet_solutions.cetia4.controller.map.AbstractMapping
All Implemented Interfaces:
Mapping
Direct Known Subclasses:
IntKeyDTO_SetMapping, MultipartBeanRequestMapper.MultipartDTOMapping, SimpleMapping

public abstract class AbstractMapping
extends java.lang.Object
implements Mapping

Base class for simple mappings with structure and utility methods. Simple mappings are mappings of one element in a form versus one simple property in a bean. More complex mapping require complete implementation of the Mapping interface.

Author:
Santiago Arriaga

Constructor Summary
protected AbstractMapping(java.lang.String fieldName, java.lang.String propertyName, boolean required)
          Public constructor, for a mapping that requires nulls.
protected AbstractMapping(java.lang.String fieldName, java.lang.String propertyName, boolean required, boolean allowsNulls)
          Public constructor.
 
Method Summary
 java.lang.String getFieldName()
          Get the field name of the current mapping
 java.lang.String getPropertyName()
          Gets the name of the property used in this mapping.
 java.lang.String getReadableName()
          Gets the readable name of the field.
 boolean isNullsAllowed()
          Get the null allowed flag of the current mapping
 boolean isRequired()
          Get the required flag of the current mapping
protected  ValidationIssue performBigDecimalMapping(java.lang.String parameter, java.lang.Object bean)
          Generic BigDecimal mapping utility method
protected  ValidationIssue performBooleanMapping(java.lang.String parameter, java.lang.Object bean)
          Generic boolean mapping utility method
protected  ValidationIssue performCalendarMapping(java.lang.String parameter, java.lang.Object bean)
          Generic Calendar mapping utility method
protected  ValidationIssue performDateMapping(java.lang.String parameter, java.lang.Object bean)
          Generic Date mapping utility method
protected  ValidationIssue performDoubleMapping(java.lang.String parameter, java.lang.Object bean)
          Generic int mapping utility method
protected  ValidationIssue performFloatMapping(java.lang.String parameter, java.lang.Object bean)
          Generic int mapping utility method
protected  ValidationIssue performIntMapping(java.lang.String parameter, java.lang.Object bean)
          Generic int mapping utility method
protected  ValidationIssue performLongMapping(java.lang.String parameter, java.lang.Object bean)
          Generic int mapping utility method
protected  ValidationIssue performStringMapping(java.lang.String parameter, java.lang.Object bean)
          Generic String mapping utility method
 void setInvalidDateMessageKey(java.lang.String invalidDateMessageKey)
          Set the invalid Date message.
 void setInvalidIntMessageKey(java.lang.String invalidIntMessageKey)
          Set the invalid int message.
 void setInvalidNumericMessageKey(java.lang.String invalidMessageKey)
          Set the invalid Numeric message.
 void setNullMessageKey(java.lang.String nullMessageKey)
          Set the null message key.
 void setNullsAllowed(boolean allowsNulls)
          Set the null allowed flag of the current mapping
protected  void setProperty(java.lang.Object bean, java.lang.Object value)
          Utility method for setting the internal configure property of the provided bean to the provided value.
 void setReadableName(java.lang.String readableName)
          Set the readable name to improve legibility in code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.acsinet_solutions.cetia4.controller.map.Mapping
performMapping
 

Constructor Detail

AbstractMapping

protected AbstractMapping(java.lang.String fieldName,
                          java.lang.String propertyName,
                          boolean required,
                          boolean allowsNulls)
Public constructor.

Parameters:
fieldName - is the name from the HTML form
propertyName - is the JavaBean property
required - true if the mapping is attempted even if no input parameter is present. Required mappings are useful for example where dealing with check boxes where the HTTP param may not travel if the component is not checked.
allowsNulls - true if the mapping resultant value allows null; false otherwise. Values mapped to primitive type typically do not accept nulls, and an empty parameter will raise an issue.

AbstractMapping

protected AbstractMapping(java.lang.String fieldName,
                          java.lang.String propertyName,
                          boolean required)
Public constructor, for a mapping that requires nulls.

Parameters:
fieldName - is the name from the HTML form
propertyName - is the JavaBean property
required - true if the mapping is attempted even if no input parameter is present. Required mappings are useful for example where dealing with check boxes where the HTTP param may not travel if the component is not checked.
allowsNulls - true if the mapping resultant value allows null; false otherwise. Values mapped to primitive type typically do not accept nulls, and an empty parameter will raise an issue.
Method Detail

getPropertyName

public final java.lang.String getPropertyName()
Gets the name of the property used in this mapping.

Specified by:
getPropertyName in interface Mapping
Returns:
A not-null String value of the property being mapped if there is a single property being mapped; a maybe null value for multiple property mappings. As this property may be null or not really a property ( multiple property mapping ) it should not be used for uses outside the ones internally implemented by the framework.
See Also:
RequestMapper.getMapping(String), RequestMapper.removeMapping(String)

getFieldName

public final java.lang.String getFieldName()
Get the field name of the current mapping


isRequired

public final boolean isRequired()
Get the required flag of the current mapping


isNullsAllowed

public final boolean isNullsAllowed()
Get the null allowed flag of the current mapping


setNullsAllowed

public final void setNullsAllowed(boolean allowsNulls)
Set the null allowed flag of the current mapping


getReadableName

public final java.lang.String getReadableName()
Gets the readable name of the field.


setReadableName

public final void setReadableName(java.lang.String readableName)
Set the readable name to improve legibility in code. By default, the field name is used.


setInvalidIntMessageKey

public final void setInvalidIntMessageKey(java.lang.String invalidIntMessageKey)
Set the invalid int message. It is a regular MessageFormat message with two optional params: {0} is the readable name or field name and {1} is the provided value.


setInvalidNumericMessageKey

public final void setInvalidNumericMessageKey(java.lang.String invalidMessageKey)
Set the invalid Numeric message. It is a regular MessageFormat message with two optional params: {0} is the readable name or field name and {1} is the provided value.


setInvalidDateMessageKey

public final void setInvalidDateMessageKey(java.lang.String invalidDateMessageKey)
Set the invalid Date message. It is a regular MessageFormat message with two optional params: {0} is the readable name or field name and {1} is the provided value.


setNullMessageKey

public final void setNullMessageKey(java.lang.String nullMessageKey)
Set the null message key. It is a regular MessageFormat message with an optional param: {0} is the readable name or field name.


performStringMapping

protected final ValidationIssue performStringMapping(java.lang.String parameter,
                                                     java.lang.Object bean)
Generic String mapping utility method


performIntMapping

protected final ValidationIssue performIntMapping(java.lang.String parameter,
                                                  java.lang.Object bean)
Generic int mapping utility method


performLongMapping

protected final ValidationIssue performLongMapping(java.lang.String parameter,
                                                   java.lang.Object bean)
Generic int mapping utility method


performFloatMapping

protected final ValidationIssue performFloatMapping(java.lang.String parameter,
                                                    java.lang.Object bean)
Generic int mapping utility method


performDoubleMapping

protected final ValidationIssue performDoubleMapping(java.lang.String parameter,
                                                     java.lang.Object bean)
Generic int mapping utility method


performBigDecimalMapping

protected final ValidationIssue performBigDecimalMapping(java.lang.String parameter,
                                                         java.lang.Object bean)
Generic BigDecimal mapping utility method


performDateMapping

protected final ValidationIssue performDateMapping(java.lang.String parameter,
                                                   java.lang.Object bean)
Generic Date mapping utility method


performCalendarMapping

protected final ValidationIssue performCalendarMapping(java.lang.String parameter,
                                                       java.lang.Object bean)
Generic Calendar mapping utility method


performBooleanMapping

protected final ValidationIssue performBooleanMapping(java.lang.String parameter,
                                                      java.lang.Object bean)
Generic boolean mapping utility method


setProperty

protected final void setProperty(java.lang.Object bean,
                                 java.lang.Object value)
Utility method for setting the internal configure property of the provided bean to the provided value. The property must be a correct Object instance assignable to the property via de Jakarta Commons PropertyUtils setProperty() method, which is much more inclusive than regular reflection methods ( for example, nested properties are supported ).

The provided bean may also bean an instance of java.util.Map, in which case the put() method of the given map will be called by this method.

Throws:
IllegalStateNestableException - Thrown if the property assignation could not be performed.