|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.request.Formats
public final class Formats
Standard display formats for the application.
The formats used by this class are mostly configured in web.xml, and are read by this class upon startup. See the User Guide for more information.
Most formats are localized using the Locale
passed to this object.
See LocaleSource
for more information.
These formats are intended for implementing standard formats for display of
data both in forms (Populate
) and in
listings (Report
).
See also DateConverter
, which is also used by this class.
Constructor Summary | |
---|---|
Formats(Locale aLocale,
TimeZone aTimeZone)
Construct with a Locale and TimeZone to be applied to non-localized patterns. |
Method Summary | |
---|---|
DecimalFormat |
getBigDecimalDisplayFormat()
Return the format in which BigDecimal s and Decimal s are displayed in a form. |
static String |
getBooleanDisplayText(Boolean aBoolean)
Return the text used to render boolean values in a report. |
Pattern |
getDecimalInputFormat()
Return the regular expression for validating the format of numeric amounts input by the user, having a possible decimal portion, with any number of decimals. |
static String |
getEmptyOrNullText()
Return the text used to render empty or null values in a report. |
DecimalFormat |
getIntegerReportDisplayFormat()
Return the format in which integer amounts are displayed in a report. |
Locale |
getLocale()
Return the Locale passed to the constructor. |
TimeZone |
getTimeZone()
Return a TimeZone of the same id as the one passed to the constructor. |
String |
objectToText(Object aObject)
Translate an object into text, suitable for presentation in an HTML form. |
SafeText |
objectToTextForReport(Object aObject)
Translate an object into text suitable for direct presentation in a JSP. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Formats(Locale aLocale, TimeZone aTimeZone)
Locale
and TimeZone
to be applied to non-localized patterns.
aLocale
- almost always comes from LocaleSource
.aTimeZone
- almost always comes from TimeZoneSource
. A defensive copy is made of
this mutable object.Method Detail |
---|
public Locale getLocale()
Locale
passed to the constructor.
public TimeZone getTimeZone()
public DecimalFormat getBigDecimalDisplayFormat()
BigDecimal
s and Decimal
s are displayed in a form.
public Pattern getDecimalInputFormat()
The returned Pattern
is controlled by a setting in web.xml,
for decimal separator(s). It is suitable for both Decimal
and BigDecimal
values.
This item is not affected by a Locale
.
See web.xml for more information.
public DecimalFormat getIntegerReportDisplayFormat()
public static String getBooleanDisplayText(Boolean aBoolean)
The return value does not depend on Locale
.
public static String getEmptyOrNullText()
The return value does not depend on Locale
. See web.xml for more information.
public String objectToText(Object aObject)
The intent of this method is to return values matching those POSTed during form submission, not the visible text presented to the user.
The returned text is not escaped in any way. That is, if special characters need to be escaped, the caller must perform the escaping.
Apply these policies in the following order :
DateTime
, apply DateConverter.formatEyeFriendlyDateTime(DateTime, Locale)
Date
, apply DateConverter.formatEyeFriendly(Date, Locale, TimeZone)
BigDecimal
, display in the form of BigDecimal.toString()
, with
one exception : the decimal separator will be as configured in web.xml.
(If the setting for the decimal separator allows for both a period and a comma,
then a period is used.)
Decimal
, display the amount only, using the same rendering as for BigDecimal
TimeZone
, return TimeZone.getID()
Code
, return Code.getId()
.toString()
Id
, return Id.getRawString()
SafeText
, return SafeText.getRawString()
If aObject is a Collection, then the caller must call this method for every element in the Collection.
aObject
- must not be a Collection.public SafeText objectToTextForReport(Object aObject)
In general, a report can be rendered in various ways: HTML, XML, plain text.
Each of these styles has different needs for escaping special characters.
This method returns a SafeText
, which can escape characters in
various ways.
This method applies the following policies to get the unescaped text :
Type | Action |
---|---|
SafeText | use SafeText.getRawString() |
Id | use Id.getRawString() |
Code | use Code.getText() .getRawString() |
hirondelle.web4.model.DateTime | apply DateConverter.formatEyeFriendlyDateTime(DateTime, Locale) |
java.util.Date | apply DateConverter.formatEyeFriendly(Date, Locale, TimeZone) |
BigDecimal | use getBigDecimalDisplayFormat() |
Decimal | use getBigDecimalDisplayFormat() on decimal.getAmount() |
Boolean | use getBooleanDisplayText(java.lang.Boolean) |
Integer | use getIntegerReportDisplayFormat() |
Long | use getIntegerReportDisplayFormat() |
Locale | use Locale.getDisplayName(java.util.Locale) |
TimeZone | use TimeZone.getDisplayName(boolean, int, java.util.Locale) (with no daylight savings hour, and in the SHORT style |
..other... |
use toString, and pass result to constructor of SafeText .
|
In addition, the value returned by getEmptyOrNullText()
is used if :
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |