A filter that formats the numeric value from a data source to a string representation
using the decimal number system as base.
This filter will format java.lang.Number objects using a java.text.DecimalFormat to
create the string representation for the date obtained from the datasource.
If the object read from the datasource is no date, the NullValue defined by
setNullValue(Object) is returned.
| Method from org.jfree.report.filter.DecimalFormatFilter Detail: |
public DecimalFormat getDecimalFormat() {
return (DecimalFormat) getFormatter();
}
Returns the format for the filter. The DecimalFormatParser has only DecimalFormat
objects assigned. |
public String getFormatString() {
return getDecimalFormat().toPattern();
}
Synthesizes a pattern string that represents the current state of this Format
object. |
public FormatSpecification getFormatString(ExpressionRuntime runtime,
Element element,
FormatSpecification formatSpecification) {
if (formatSpecification == null)
{
formatSpecification = new FormatSpecification();
}
formatSpecification.redefine(FormatSpecification.TYPE_DECIMAL_FORMAT, getFormatString());
return formatSpecification;
}
|
public String getLocalizedFormatString() {
return getDecimalFormat().toLocalizedPattern();
}
Synthesizes a localized pattern string that represents the current state of this
Format object. |
public Object getValue(ExpressionRuntime runtime,
Element element) {
if (keepState == false && runtime != null)
{
final Locale locale = runtime.getResourceBundleFactory().getLocale();
if (locale != null && locale.equals(lastLocale) == false)
{
lastLocale = locale;
getDecimalFormat().setDecimalFormatSymbols(new DecimalFormatSymbols(locale));
invalidateCache();
}
}
return super.getValue(runtime, element);
}
Returns the formatted string. The value is read using the data source given and
formated using the formatter of this object. The formating is guaranteed to completly
form the object to an string or to return the defined NullValue.
If format, datasource or object are null, the NullValue is returned. |
public boolean isKeepState() {
return keepState;
}
Defines, whether the filter should keep its state, if a locale
change is detected. This will effectivly disable the locale update. |
public void setDecimalFormat(DecimalFormat format) {
setFormatter(format);
}
Sets the format for the filter. |
public void setFormatString(String format) {
getDecimalFormat().applyPattern(format);
invalidateCache();
}
Applies a format string to the internal DecimalFormat instance. |
public void setFormatter(Format format) {
final DecimalFormat dfmt = (DecimalFormat) format;
super.setFormatter(dfmt);
}
Sets the format for the filter. If the given format is no Decimal format, a
ClassCastException is thrown |
public void setKeepState(boolean keepState) {
this.keepState = keepState;
}
Defines, whether the filter should keep its state, if a locale
change is detected. This will effectivly disable the locale update. |
public void setLocalizedFormatString(String format) {
getDecimalFormat().applyLocalizedPattern(format);
invalidateCache();
}
Applies a localised format string to the internal DecimalFormat
instance. |