com.acsinet_solutions.cetia4.controller.map
Interface RequestMapper

All Known Implementing Classes:
AbstractBeanRequestMapper, BeanRequestMapper, MultipartBeanRequestMapper, SimpleRequestMapper

public interface RequestMapper

This is the basic interface for request mappers, that defines the contract for configuring and executing mappings in a web environment from String HTTP parameters ( or a similar source ) and arbitrary objects.

Author:
Santiago Arriaga

Method Summary
 void addMapping(Mapping mapping)
          Add a mapping to the mapper.
 Mapping getMapping(java.lang.String propertyName)
          Gets the mapping for a given property.
 java.util.Collection<Mapping> getMappings()
          Get a reference to a read-only collection with all the mappings.
 SimpleMapping getSimpleMapping(java.lang.String propertyName)
          Gets the simple mapping for a given property.
 void performMapping(ParameterAccessor request, java.lang.Object bean)
          Perform the mapping from the HTTP request values to the provided bean using a generic parameter accesor API.
 void performMapping(javax.servlet.ServletRequest request, java.lang.Object bean)
          Perform the mapping from the HTTP request values to the provided bean in the case of the servlet API.
 void removeMapping(java.lang.String propertyName)
          Removes the mapping for a given property.
 void setMapping(Mapping mapping)
          Sets the mapping for a given property.
 void setValidator(Validator validator)
          Set an optional validation reference.
 

Method Detail

addMapping

void addMapping(Mapping mapping)
Add a mapping to the mapper. Does not check if a mapping for the given property exist.


setMapping

void setMapping(Mapping mapping)
Sets the mapping for a given property. If a mapping with property name equal to the one returned by the getPropertyName() of the given mapping exists.

See Also:
Mapping.getPropertyName()

removeMapping

void removeMapping(java.lang.String propertyName)
Removes the mapping for a given property. Mappings for the given property name are searched and deleted. If a mapping does not return a valid or not-null property name in getPropertyName() this method may not be able to delete the given mapping.

See Also:
Mapping.getPropertyName()

getMapping

Mapping getMapping(java.lang.String propertyName)
Gets the mapping for a given property. This is useful for changing default mappings. All default mappings are subclasses of SimpleMapping so a cast can be safely performed in this cases, or getSimpleMapping() convenience method can be used.

See Also:
Mapping.getPropertyName()

getSimpleMapping

SimpleMapping getSimpleMapping(java.lang.String propertyName)
Gets the simple mapping for a given property. This method is useful when reading default mappings, for example, to change them their associated message. All default mappings created by a RequestMapper such as BeanRequestMapper will always extend SimpleMapping. Custom mappings may not extend this class, so this method should only be used when dealing with default mappings.


getMappings

java.util.Collection<Mapping> getMappings()
Get a reference to a read-only collection with all the mappings. This may be useful to access mappings that are not accesible using it's property name.


setValidator

void setValidator(Validator validator)
Set an optional validation reference. Validation may be performed as part of the mapping, and validating here has the advantage that all validation errors are reported simultaneously. The validation method that is called in this validator when mapping is the generic validate() method, not the specific insert or update validate() methods, so beware of this.

See Also:
Validator.validate(ValidationIssueBuilder,Object)

performMapping

void performMapping(javax.servlet.ServletRequest request,
                    java.lang.Object bean)
                    throws ValidationException
Perform the mapping from the HTTP request values to the provided bean in the case of the servlet API.

Validation is performed in addition to the mapping, if a validator was set for the current request mapper.

Throws:
ValidationException
See Also:
setValidator(Validator)

performMapping

void performMapping(ParameterAccessor request,
                    java.lang.Object bean)
                    throws ValidationException
Perform the mapping from the HTTP request values to the provided bean using a generic parameter accesor API. This allows to use the request mapping classes in a more wide variety of environments, not only web based.

Validation is performed in addition to the mapping, if a validator was set for the current request mapper.

Throws:
ValidationException
See Also:
setValidator(Validator)