Class NumberFormatFilter

  • All Implemented Interfaces:
    Serializable, Cloneable, DataFilter, DataSource, DataTarget, RawDataSource
    Direct Known Subclasses:
    DecimalFormatFilter

    public class NumberFormatFilter
    extends FormatFilter
    A filter that formats the numeric value from a data source to a string representation.

    This filter will format java.lang.Number objects using a java.text.NumericFormat to create the string representation for the number obtained from the datasource.

    If the object read from the datasource is no number, the NullValue defined by setNullValue(Object) is returned.

    Author:
    Thomas Morgner
    See Also:
    NumberFormat, Serialized Form
    • Constructor Detail

      • NumberFormatFilter

        public NumberFormatFilter()
        Default constructor.

        Uses a general number format for the current locale.

    • Method Detail

      • setNumberFormat

        public void setNumberFormat​(NumberFormat nf)
        Sets the number format.
        Parameters:
        nf - The number format.
      • getNumberFormat

        public NumberFormat getNumberFormat()
        Returns the number format.
        Returns:
        The number format.
      • setFormatter

        public void setFormatter​(Format f)
        Sets the formatter.
        Overrides:
        setFormatter in class FormatFilter
        Parameters:
        f - The format.
      • setGroupingUsed

        public void setGroupingUsed​(boolean newValue)
        Turns grouping on or off for the current number format.
        Parameters:
        newValue - The new value of the grouping flag.
      • isGroupingUsed

        public boolean isGroupingUsed()
        Returns the value of the grouping flag for the current number format.
        Returns:
        The grouping flag.
      • setMaximumFractionDigits

        public void setMaximumFractionDigits​(int newValue)
        Sets the maximum number of fraction digits for the current number format.
        Parameters:
        newValue - The number of digits.
      • getMaximumFractionDigits

        public int getMaximumFractionDigits()
        Returns the maximum number of fraction digits.
        Returns:
        The digits.
      • setMaximumIntegerDigits

        public void setMaximumIntegerDigits​(int newValue)
        Sets the maximum number of digits in the integer part of the current number format.
        Parameters:
        newValue - The number of digits.
      • getMaximumIntegerDigits

        public int getMaximumIntegerDigits()
        Returns the maximum number of integer digits.
        Returns:
        The digits.
      • setMinimumFractionDigits

        public void setMinimumFractionDigits​(int newValue)
        Sets the minimum number of fraction digits for the current number format.
        Parameters:
        newValue - The number of digits.
      • getMinimumFractionDigits

        public int getMinimumFractionDigits()
        Returns the minimum number of fraction digits.
        Returns:
        The digits.
      • setMinimumIntegerDigits

        public void setMinimumIntegerDigits​(int newValue)
        Sets the minimum number of digits in the integer part of the current number format.
        Parameters:
        newValue - The number of digits.
      • getMinimumIntegerDigits

        public int getMinimumIntegerDigits()
        Returns the minimum number of integer digits.
        Returns:
        The digits.
      • getFormatString

        public FormatSpecification getFormatString​(ExpressionRuntime runtime,
                                                   ReportElement element,
                                                   FormatSpecification formatSpecification)
        Description copied from interface: RawDataSource
        Returns information about the formatstring that was used to transform a raw-value into a formatted text. Not all elements will make use of a format-string. These elements will return .classic.core.filter.FormatSpecification#TYPE_UNDEFINED in that case.
        Specified by:
        getFormatString in interface RawDataSource
        Overrides:
        getFormatString in class FormatFilter
        Parameters:
        runtime - the Expression runtime used to possibly compute the raw-value.
        element - the element to which this datasource is added.
        formatSpecification - the format specification (can be null). @return a filled format specififcation. If the formatSpecification parameter was not null, this given instance is reused.