Package net.sf.jguiraffe.transform
Class TimeTransformer
- java.lang.Object
-
- net.sf.jguiraffe.transform.DateTransformerBase
-
- net.sf.jguiraffe.transform.TimeTransformer
-
- All Implemented Interfaces:
Transformer
,Validator
public class TimeTransformer extends DateTransformerBase
A specialized transformer that transforms strings into date objects, taking only the time portion into account.
Most of the required functionality is already implemented by the base class. This class only creates an appropriate
DateFormat
object that supports parsing time values.For the documentation of the supported properties refer to the super class. The error messaged produced by this class are analogous to the ones used by
DateTransformerBase
, but specific for time objects. So an application can display different error messages for invalid date and time inputs. The following table lists the possible error messages:Message key Description Parameters "ERR_INVALID_TIME"
The passed in string cannot be parsed to a time object. {0} = the time string "ERR_TIME_AFTER"
The entered time must be after the reference date. {0} = the (formatted) reference date "ERR_TIME_AFTER_EQUAL"
The entered time must be after or equal the reference date. {0} = the (formatted) reference date "ERR_TIME_BEFORE"
The entered time must be before the reference date. {0} = the (formatted) reference date "ERR_TIME_BEFORE_EQUAL"
The entered time must be before or equal the reference date. {0} = the (formatted) reference date - Version:
- $Id: TimeTransformer.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
- See Also:
ValidationMessageConstants
-
-
Field Summary
-
Fields inherited from class net.sf.jguiraffe.transform.DateTransformerBase
PROP_AFTER, PROP_BEFORE, PROP_EQUAL, PROP_LENIENT, PROP_REFERENCE_DATE, PROP_STYLE
-
-
Constructor Summary
Constructors Constructor Description TimeTransformer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DateFormat
createFormat(Locale locale, int style, org.apache.commons.configuration.Configuration config)
Returns a format object for formatting and parsing time objects.protected ValidationResult
errorResult(String errorKey, TransformerContext ctx, Object... params)
Returns a validation result object with an error message.-
Methods inherited from class net.sf.jguiraffe.transform.DateTransformerBase
getDefaultReferenceDate, getReferenceDate, getReferenceDateProperty, getStyle, initializeFormat, isAfter, isBefore, isDateValid, isEqual, isLenient, isValid, setAfter, setBefore, setEqual, setLenient, setReferenceDate, setStyle, transform, transformDate, transformSqlDate, transformToDate, transformToString, updateDatePart, updateTimePart
-
-
-
-
Method Detail
-
createFormat
protected DateFormat createFormat(Locale locale, int style, org.apache.commons.configuration.Configuration config)
Returns a format object for formatting and parsing time objects.- Specified by:
createFormat
in classDateTransformerBase
- Parameters:
locale
- the localestyle
- the style to be usedconfig
- the configuration with the current properties- Returns:
- the format object
-
errorResult
protected ValidationResult errorResult(String errorKey, TransformerContext ctx, Object... params)
Returns a validation result object with an error message. This implementation transforms error messages for invalid dates to messages for invalid times.- Overrides:
errorResult
in classDateTransformerBase
- Parameters:
errorKey
- the key of the error messagectx
- the transformer contextparams
- additional parameters- Returns:
- the validation result object with the specified error message
-
-