Version 4.10.0

hirondelle.web4j.model
Class ConvertParamImpl

Object
  extended by hirondelle.web4j.model.ConvertParamImpl
All Implemented Interfaces:
ConvertParam

public class ConvertParamImpl
extends Object
implements ConvertParam

Default implementation of ConvertParam.


Constructor Summary
ConvertParamImpl()
           
 
Method Summary
<T> T
convert(String aFilteredInputValue, Class<T> aSupportedTargetClass, Locale aLocale, TimeZone aTimeZone)
          Apply reasonable parsing policies, suitable for most applications.
 String filter(String aRawInputValue)
          Coerce all parameters with no visible content to null.
 String getIgnorableParamValue()
          Return the IgnorableParamValue configured in web.xml.
 boolean isSupported(Class<?> aTargetClass)
          Return true only if aTargetClass is supported by this implementation.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvertParamImpl

public ConvertParamImpl()
Method Detail

isSupported

public final boolean isSupported(Class<?> aTargetClass)
Return true only if aTargetClass is supported by this implementation.

The following classes are supported by this implementation as building block classes:

You are not obliged to use this class to model Locale and TimeZone. Many will choose to implement them as just another code table instead. In this case, your model object constructors would usually take an Id parameter for these items, and translate them into a Code. See the example apps for a demonstration of this technique.

String is supported only when explicitly allowed. The AllowStringAsBuildingBlock setting in web.xml controls whether or not this class allows String as a supported class. By default, its value is FALSE, since SafeText is the recommended replacement for String.

Specified by:
isSupported in interface ConvertParam

filter

public String filter(String aRawInputValue)
Coerce all parameters with no visible content to null.

In addition, any raw input value that matches IgnorableParamValue in web.xml is also coerced to null. See web.xml for more information.

Any non-null result is trimmed. This method can be overridden, if desired.

Specified by:
filter in interface ConvertParam
Parameters:
aRawInputValue - the raw, unchanged parameter value, as submitted in the underlying request.

convert

public final <T> T convert(String aFilteredInputValue,
                           Class<T> aSupportedTargetClass,
                           Locale aLocale,
                           TimeZone aTimeZone)
                throws ModelCtorException
Apply reasonable parsing policies, suitable for most applications.

Roughly, the policies are:

InputStreams are not converted by this class, and need to be handled separately by the caller.

Specified by:
convert in interface ConvertParam
Parameters:
aFilteredInputValue - parameter value as returned by ConvertParam.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

getIgnorableParamValue

public final String getIgnorableParamValue()
Return the IgnorableParamValue configured in web.xml. See web.xml for more information.


Version 4.10.0

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