Version 4.10.0

hirondelle.web4j.request
Class Formats

Object
  extended by hirondelle.web4j.request.Formats

public final class Formats
extends Object

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 BigDecimals and Decimals 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

Formats

public Formats(Locale aLocale,
               TimeZone aTimeZone)
Construct with a Locale and TimeZone to be applied to non-localized patterns.

Parameters:
aLocale - almost always comes from LocaleSource.
aTimeZone - almost always comes from TimeZoneSource. A defensive copy is made of this mutable object.
Method Detail

getLocale

public Locale getLocale()
Return the Locale passed to the constructor.


getTimeZone

public TimeZone getTimeZone()
Return a TimeZone of the same id as the one passed to the constructor.


getBigDecimalDisplayFormat

public DecimalFormat getBigDecimalDisplayFormat()
Return the format in which BigDecimals and Decimals are displayed in a form.


getDecimalInputFormat

public 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.

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.


getIntegerReportDisplayFormat

public DecimalFormat getIntegerReportDisplayFormat()
Return the format in which integer amounts are displayed in a report.


getBooleanDisplayText

public static String getBooleanDisplayText(Boolean aBoolean)
Return the text used to render boolean values in a report.

The return value does not depend on Locale.


getEmptyOrNullText

public static String getEmptyOrNullText()
Return the text used to render empty or null values in a report.

The return value does not depend on Locale. See web.xml for more information.


objectToText

public String objectToText(Object aObject)
Translate an object into text, suitable for presentation in an HTML form.

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 :

If aObject is a Collection, then the caller must call this method for every element in the Collection.

Parameters:
aObject - must not be a Collection.

objectToTextForReport

public SafeText objectToTextForReport(Object aObject)
Translate an object into text suitable for direct presentation in a JSP.

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

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