Package org.cyclos.model.utils
Class AbstractFormatter
- java.lang.Object
-
- org.cyclos.model.utils.AbstractFormatter
-
- All Implemented Interfaces:
Formatter
- Direct Known Subclasses:
FormatterImpl
public abstract class AbstractFormatter extends Object implements Formatter
Base implementation for formatters
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringTIMESTAMP_PATTERNPattern used to format timestamps.-
Fields inherited from interface org.cyclos.utils.Formatter
VARIABLE_SCALE
-
-
Constructor Summary
Constructors Constructor Description AbstractFormatter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringfixSignIfZero(String formattedValue)It removes the starting minus sign ('-') if the formatted value represents the zero number.Stringformat(Boolean bool)Formats a booleanStringformat(Integer number)Formats an integer numberStringformat(Long number)Formats a long numberStringformat(Number size, FileSizeUnit unit)Formats a size showing its unitsStringformat(Object object)Tests the object type, invoking one of the specific format methodsStringformat(Collection<?> list)Formats a collection as a comma-separated string, invokingFormatter.format(Object)for each elementStringformat(AccountOwner accountOwner)Formats an account ownerStringformat(ICurrency currency, BigDecimal amount)Formats an amount with the given currencyStringformat(FormattableTimeBasedRate rate)Formats a time based rateStringformat(IBinaryFile file)Formats a binary fileStringformat(INamedEntity namedEntity)Formats a named entityStringformat(ICustomFieldPossibleValue<?> possibleValue)Formats a custom field possible valueStringformat(ICustomFieldValue<?,?,?,?> customFieldValue)Formats a custom field valueStringformat(IDynamicFieldValue dynamicValue)Formats a custom field dynamic valueStringformat(IImage image)Formats an imageStringformat(ProfileField profileField)Formats a user profile fieldStringformat(HasDisplay hasDisplay)Formats the given object as the display valueStringformat(ICurrencyAmount currencyAmount)Formats a currency amountStringformat(ICurrencyAmountRange range)Formats a currency amount rangeStringformat(IDatePeriod period)Formats a periodStringformat(IDecimalRange range, int scale)Formats a decimal range with the given scaleStringformat(IDimensions dimensions)Formats a dimensionsStringformat(IFileSize fileSize)Formats a file sizeStringformat(ILatLong latLong)Formats a geographical coordinateStringformat(ITimeInterval timeInterval)Formats a time intervalStringformat(Range<?> range)Formats a rangeStringformat(HasMessageKey hasKey)Formats an object that has a mapping to the translation message key.Stringformat(TranslationMessageSpecification tms)Formats a translation messageStringformatAsDate(IDatePeriod period)Formats a period as dateStringformatDuration(Long duration)Formats a duration (given in milliseconds) in a string like: 1h 12m 31sStringformatPercentage(Double number)Formats a percentage with variable scaleStringformatPercentage(Double number, int scale)Formats a percentage with the given decimal digitsStringformatPercentage(Integer value, Integer total)Formats a percentage without decimal fieldsStringformatPercentage(Integer value, Integer total, int scale)Formats a percentage with the given decimal digitsStringformatPercentage(BigDecimal number)Formats a percentage with variable scaleStringformatPercentage(BigDecimal number, int scale)Formats a percentage with the given decimal fieldsprotected StringformatPeriod(String begin, String end)protected StringformatRange(String min, String max)StringformatRelated(AccountVO account)Formats the account as related to be shown in the result list Used in archived-account-history.htmlprotected abstract Stringmessage(MessageFormat format, MessageKey key, Object... arguments)protected Stringmessage(MessageKey key, Object... arguments)protected BigDecimalroundHour(BigDecimal hour, BigDecimal minutes, BigDecimal seconds)Rounds the given hour half up with seconds precisionprotected Pair<BigDecimal,BigDecimal>splitDecimal(BigDecimal value)Returns a pair with the integer part and the decimal part of the given number-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.utils.Formatter
format, format, formatAsDate, formatAsTime, formatAsTimestamp, formatId, getDatePattern, getTimePattern
-
-
-
-
Field Detail
-
TIMESTAMP_PATTERN
protected static String TIMESTAMP_PATTERN
Pattern used to format timestamps. Changes to this pattern should be reflected inTimeFormat.format(org.cyclos.utils.DateTime, String)
-
-
Method Detail
-
format
public String format(AccountOwner accountOwner)
Description copied from interface:FormatterFormats an account owner
-
format
public String format(Boolean bool)
Description copied from interface:FormatterFormats a boolean
-
format
public String format(Collection<?> list)
Description copied from interface:FormatterFormats a collection as a comma-separated string, invokingFormatter.format(Object)for each element
-
format
public String format(FormattableTimeBasedRate rate)
Description copied from interface:FormatterFormats a time based rate
-
format
public String format(HasDisplay hasDisplay)
Description copied from interface:FormatterFormats the given object as the display value
-
format
public String format(HasMessageKey hasKey)
Description copied from interface:FormatterFormats an object that has a mapping to the translation message key.
-
format
public String format(IBinaryFile file)
Description copied from interface:FormatterFormats a binary file
-
format
public String format(ICurrency currency, BigDecimal amount)
Description copied from interface:FormatterFormats an amount with the given currency
-
format
public String format(ICurrencyAmount currencyAmount)
Description copied from interface:FormatterFormats a currency amount
-
format
public String format(ICurrencyAmountRange range)
Description copied from interface:FormatterFormats a currency amount range
-
format
public String format(ICustomFieldPossibleValue<?> possibleValue)
Description copied from interface:FormatterFormats a custom field possible value
-
format
public String format(ICustomFieldValue<?,?,?,?> customFieldValue)
Description copied from interface:FormatterFormats a custom field value
-
format
public String format(IDatePeriod period)
Description copied from interface:FormatterFormats a period
-
format
public String format(IDecimalRange range, int scale)
Description copied from interface:FormatterFormats a decimal range with the given scale
-
format
public String format(IDimensions dimensions)
Description copied from interface:FormatterFormats a dimensions
-
format
public String format(IDynamicFieldValue dynamicValue)
Description copied from interface:FormatterFormats a custom field dynamic value
-
format
public String format(IFileSize fileSize)
Description copied from interface:FormatterFormats a file size
-
format
public String format(IImage image)
Description copied from interface:FormatterFormats an image
-
format
public String format(ILatLong latLong)
Description copied from interface:FormatterFormats a geographical coordinate
-
format
public String format(INamedEntity namedEntity)
Description copied from interface:FormatterFormats a named entity
-
format
public String format(Integer number)
Description copied from interface:FormatterFormats an integer number
-
format
public String format(ITimeInterval timeInterval)
Description copied from interface:FormatterFormats a time interval
-
format
public String format(Long number)
Description copied from interface:FormatterFormats a long number
-
format
public String format(Number size, FileSizeUnit unit)
Description copied from interface:FormatterFormats a size showing its units
-
format
public String format(Object object)
Description copied from interface:FormatterTests the object type, invoking one of the specific format methods
-
format
public String format(ProfileField profileField)
Description copied from interface:FormatterFormats a user profile field
-
format
public String format(Range<?> range)
Description copied from interface:FormatterFormats a range
-
format
public String format(TranslationMessageSpecification tms)
Description copied from interface:FormatterFormats a translation message
-
formatAsDate
public String formatAsDate(IDatePeriod period)
Description copied from interface:FormatterFormats a period as date- Specified by:
formatAsDatein interfaceFormatter
-
formatDuration
public String formatDuration(Long duration)
Description copied from interface:FormatterFormats a duration (given in milliseconds) in a string like: 1h 12m 31s- Specified by:
formatDurationin interfaceFormatter
-
formatPercentage
public String formatPercentage(BigDecimal number)
Description copied from interface:FormatterFormats a percentage with variable scale- Specified by:
formatPercentagein interfaceFormatter
-
formatPercentage
public String formatPercentage(BigDecimal number, int scale)
Description copied from interface:FormatterFormats a percentage with the given decimal fields- Specified by:
formatPercentagein interfaceFormatter
-
formatPercentage
public String formatPercentage(Double number)
Description copied from interface:FormatterFormats a percentage with variable scale- Specified by:
formatPercentagein interfaceFormatter
-
formatPercentage
public String formatPercentage(Double number, int scale)
Description copied from interface:FormatterFormats a percentage with the given decimal digits- Specified by:
formatPercentagein interfaceFormatter
-
formatPercentage
public String formatPercentage(Integer value, Integer total)
Description copied from interface:FormatterFormats a percentage without decimal fields- Specified by:
formatPercentagein interfaceFormatter
-
formatPercentage
public String formatPercentage(Integer value, Integer total, int scale)
Description copied from interface:FormatterFormats a percentage with the given decimal digits- Specified by:
formatPercentagein interfaceFormatter
-
formatRelated
public String formatRelated(AccountVO account)
Description copied from interface:FormatterFormats the account as related to be shown in the result list Used in archived-account-history.html- Specified by:
formatRelatedin interfaceFormatter
-
fixSignIfZero
protected String fixSignIfZero(String formattedValue)
It removes the starting minus sign ('-') if the formatted value represents the zero number.- Parameters:
formattedValue- an already formatted value with some scale- Returns:
- the formattedValue parameter without the minus sign if it represents the zero number.
-
message
protected abstract String message(MessageFormat format, MessageKey key, Object... arguments)
-
message
protected final String message(MessageKey key, Object... arguments)
-
roundHour
protected BigDecimal roundHour(BigDecimal hour, BigDecimal minutes, BigDecimal seconds)
Rounds the given hour half up with seconds precision
-
splitDecimal
protected Pair<BigDecimal,BigDecimal> splitDecimal(BigDecimal value)
Returns a pair with the integer part and the decimal part of the given number
-
-