com.endeca.portal.format
Class DurationFormatter

java.lang.Object
  extended by com.endeca.portal.format.Formatter
      extended by com.endeca.portal.format.DurationFormatter
All Implemented Interfaces:
DurationFormatSettings, FormatSettings, java.io.Serializable

public class DurationFormatter
extends Formatter
implements DurationFormatSettings

Formatter for formatting Duration type based on locale and format settings. If the value of a format setting is DEFAULT, the value of the format setting of its parent will be used if it is not DEFAULT. Otherwise, system default value of that format setting will be used. The precision unit strings "days", "hours", "minutes", "seconds" and "milliseconds" are locale sensitive. The resources for them are stored in resource bundle. It is caller's responsibility to call setLocalizedPrecisionUnitStrings() to pass in the localized resources.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.endeca.portal.format.Formatter
Formatter.FormatParseException
 
Nested classes/interfaces inherited from interface com.endeca.portal.format.DurationFormatSettings
DurationFormatSettings.DecimalPlacesMode, DurationFormatSettings.IncludePrecisionUnit, DurationFormatSettings.Precision
 
Nested classes/interfaces inherited from interface com.endeca.portal.format.FormatSettings
FormatSettings.Type
 
Field Summary
static int DEFAULT_DECIMAL_PLACES
           
static DurationFormatSettings.DecimalPlacesMode DEFAULT_DECIMAL_PLACES_MODE
           
static DurationFormatSettings.IncludePrecisionUnit DEFAULT_INCLUDE_PRECISION_UNIT
           
static DurationFormatSettings.Precision DEFAULT_PRECISION
           
 
Fields inherited from class com.endeca.portal.format.Formatter
parentFormatSettings, type
 
Constructor Summary
DurationFormatter()
           
 
Method Summary
protected  void clearCachedJavaFormat()
           
protected  void createJavaFormat()
           
 java.lang.String format(java.lang.String str)
           
protected  java.text.NumberFormat getCachedJavaFormat()
           
 int getDecimalPlaces()
           
 DurationFormatSettings.DecimalPlacesMode getDecimalPlacesMode()
           
 DurationFormatSettings.IncludePrecisionUnit getIncludePrecisionUnit()
           
 int getMergedDecimalPlaces()
           
 DurationFormatSettings.DecimalPlacesMode getMergedDecimalPlacesMode()
           
 DurationFormatSettings.IncludePrecisionUnit getMergedIncludePrecisionUnit()
           
 DurationFormatSettings.Precision getMergedPrecision()
           
 DurationFormatSettings.Precision getPrecision()
           
protected  void initializeJavaFormat()
           
protected  void loadResources(javax.portlet.PortletRequest request)
          Subclasses need to override this method to load resources when needed.
protected  void localeChanged()
          Subclasses can override this method to clear/reset some cached data that is dependent on locale, for example cached Java format.
protected  void parentFormatSettingsChanged()
          Subclasses can override this method to clear/reset some cached data that is dependent on parent format settings, for example cached Java format.
static double parseSeconds(java.lang.String mdexValue)
           
 void setDecimalPlaces(int decimalPlaces)
           
 void setDecimalPlacesMode(DurationFormatSettings.DecimalPlacesMode decimalPlacesMode)
           
 void setIncludePrecisionUnit(DurationFormatSettings.IncludePrecisionUnit includePrecisionUnit)
           
 void setPrecision(DurationFormatSettings.Precision precision)
           
 
Methods inherited from class com.endeca.portal.format.Formatter
getLocale, getParentFormatSettings, getType, setLocale, setLocale, setParentFormatSettings, setType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.endeca.portal.format.FormatSettings
getType, toString
 

Field Detail

DEFAULT_PRECISION

public static final DurationFormatSettings.Precision DEFAULT_PRECISION

DEFAULT_INCLUDE_PRECISION_UNIT

public static final DurationFormatSettings.IncludePrecisionUnit DEFAULT_INCLUDE_PRECISION_UNIT

DEFAULT_DECIMAL_PLACES_MODE

public static final DurationFormatSettings.DecimalPlacesMode DEFAULT_DECIMAL_PLACES_MODE

DEFAULT_DECIMAL_PLACES

public static final int DEFAULT_DECIMAL_PLACES
See Also:
Constant Field Values
Constructor Detail

DurationFormatter

public DurationFormatter()
Method Detail

loadResources

protected void loadResources(javax.portlet.PortletRequest request)
Description copied from class: Formatter
Subclasses need to override this method to load resources when needed.

Overrides:
loadResources in class Formatter

getPrecision

public DurationFormatSettings.Precision getPrecision()
Specified by:
getPrecision in interface DurationFormatSettings

setPrecision

public void setPrecision(DurationFormatSettings.Precision precision)

getMergedPrecision

public DurationFormatSettings.Precision getMergedPrecision()
Specified by:
getMergedPrecision in interface DurationFormatSettings

getIncludePrecisionUnit

public DurationFormatSettings.IncludePrecisionUnit getIncludePrecisionUnit()
Specified by:
getIncludePrecisionUnit in interface DurationFormatSettings

setIncludePrecisionUnit

public void setIncludePrecisionUnit(DurationFormatSettings.IncludePrecisionUnit includePrecisionUnit)

getMergedIncludePrecisionUnit

public DurationFormatSettings.IncludePrecisionUnit getMergedIncludePrecisionUnit()
Specified by:
getMergedIncludePrecisionUnit in interface DurationFormatSettings

getDecimalPlacesMode

public DurationFormatSettings.DecimalPlacesMode getDecimalPlacesMode()
Specified by:
getDecimalPlacesMode in interface DurationFormatSettings

setDecimalPlacesMode

public void setDecimalPlacesMode(DurationFormatSettings.DecimalPlacesMode decimalPlacesMode)

getMergedDecimalPlacesMode

public DurationFormatSettings.DecimalPlacesMode getMergedDecimalPlacesMode()
Specified by:
getMergedDecimalPlacesMode in interface DurationFormatSettings

getDecimalPlaces

public int getDecimalPlaces()
Specified by:
getDecimalPlaces in interface DurationFormatSettings

setDecimalPlaces

public void setDecimalPlaces(int decimalPlaces)

getMergedDecimalPlaces

public int getMergedDecimalPlaces()
Specified by:
getMergedDecimalPlaces in interface DurationFormatSettings

localeChanged

protected void localeChanged()
Description copied from class: Formatter
Subclasses can override this method to clear/reset some cached data that is dependent on locale, for example cached Java format.

Overrides:
localeChanged in class Formatter

parentFormatSettingsChanged

protected void parentFormatSettingsChanged()
Description copied from class: Formatter
Subclasses can override this method to clear/reset some cached data that is dependent on parent format settings, for example cached Java format.

Overrides:
parentFormatSettingsChanged in class Formatter

clearCachedJavaFormat

protected void clearCachedJavaFormat()

createJavaFormat

protected void createJavaFormat()

initializeJavaFormat

protected void initializeJavaFormat()

getCachedJavaFormat

protected java.text.NumberFormat getCachedJavaFormat()

parseSeconds

public static double parseSeconds(java.lang.String mdexValue)
                           throws Formatter.FormatParseException
Throws:
Formatter.FormatParseException

format

public java.lang.String format(java.lang.String str)
                        throws Formatter.FormatParseException
Specified by:
format in class Formatter
Throws:
Formatter.FormatParseException