Version 4.10.0

hirondelle.web4j.model
Interface ConvertParam

All Known Implementing Classes:
ConvertParamImpl

public interface ConvertParam

Convert request parameters into common 'building block' objects.

See BuildImpl for important information on how this item is configured. BuildImpl.forConvertParam() returns the configured implementation of this interface.

Building Block Classes

Here, a building block class is one of the 'base' objects from which Model Objects can in turn be built - Integer, BigDecimal, Date, and so on. isSupported(Class) defines which classes are supported as building block classes, and convert(String, Class, Locale, TimeZone) defines how to construct them from request parameters.

ConvertParamImpl is provided as a default implementation, and is likely suitable for many applications.

In addition, implementations may optionally choose to apply universal pre-processing for Strings. For example, an implementation may decide to trim all Strings, or to force capitalization for all Strings. Such policies may be centralized here, by including them in the implementation of filter(String) or convert(String, Class, Locale, TimeZone).


Method Summary
<T> T
convert(String aFilteredParamValue, Class<T> aSupportedTargetClass, Locale aLocale, TimeZone aTimeZone)
          Convert a request parameter value into a building block object.
 String filter(String aRawParamValue)
          Apply a policy for parameter values which are null, empty, or equal to IgnorableParamValue in web.xml.
 boolean isSupported(Class<?> aTargetClass)
          Determine if aTargetClass is a supported building block class.
 

Method Detail

isSupported

boolean isSupported(Class<?> aTargetClass)
Determine if aTargetClass is a supported building block class.

If aTargetClass is supported, then an underlying request parameter can be converted into an object of that class.

The framework will always call this method first, before calling the other methods in this interface.


filter

String filter(String aRawParamValue)
Apply a policy for parameter values which are null, empty, or equal to IgnorableParamValue in web.xml.

When a 'blank' form is submitted, items are not treated in a uniform manner. For example, a popular browser exhibits this behavior :

Moreover, the W3C spec seems to allow for some ambiguity in what exactly is posted, so the above behavior may not be seen for all browsers.

This method is used to impose uniformity upon all such 'blank' items.

This method can return null. Any non-null values returned by this method must have content. (That is, an implementation cannot return a String which, when trimmed, is empty.)

Parameters:
aRawParamValue - the raw, unchanged parameter value, as submitted in the underlying request.

convert

<T> T convert(String aFilteredParamValue,
              Class<T> aSupportedTargetClass,
              Locale aLocale,
              TimeZone aTimeZone)
          throws ModelCtorException
Convert a request parameter value into a building block object.

The value passed to this method is first filtered, using filter(String). Implementations must throw a ModelCtorException when a parsing problem occurs.

Parameters:
aFilteredParamValue - parameter value as returned by filter(String)
aSupportedTargetClass - supported target building block class in a Model Object constructor
aLocale - Locale returned by the implementation of LocaleSource
aTimeZone - TimeZone returned by the implementation of TimeZoneSource
Throws:
ModelCtorException

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.