Class DateFormatParser

    • Constructor Detail

      • DateFormatParser

        public DateFormatParser()
        Creates a new 'date format parser'.
    • Method Detail

      • getDateFormat

        public DateFormat getDateFormat()
        Returns the format for this filter. The format object is returned as DateFormat.
        the formatter.
        NullPointerException - if the given format is null
      • setDateFormat

        public void setDateFormat​(DateFormat format)
        Sets the format for the filter.
        format - The format.
        NullPointerException - if the given format is null
      • getValue

        public Object getValue​(ExpressionRuntime runtime,
                               ReportElement element)
        Description copied from class: FormatParser
        Returns the parsed object. The value is read using the data source given and parsed using the formatter of this object. The parsing is guaranteed to completly form the target object or to return the defined NullValue.

        If the given datasource does not return a string, the returned object is transformed into a string using String.valueOf (Object) and then parsed.

        If format, datasource or object are null, the NullValue is returned.

        Specified by:
        getValue in interface DataSource
        getValue in class FormatParser
        runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.
        element - the element for which the data is computed.
        The formatted value.
      • setNullValue

        public void setNullValue​(Object nullvalue)
        Sets the value that will be displayed if the data source supplies a null value. The nullValue itself can be null to cover the case when no reasonable default value can be defined.

        The null value for date format parsers is required to be either null or a java.util.Date.

        setNullValue in class FormatParser
        nullvalue - the nullvalue returned when parsing failed.
        ClassCastException - if the value is no date or not null.
      • isValidOutput

        protected boolean isValidOutput​(Object o)
        Checks whether the given value is already a valid result. IF the datasource already returned a valid value, and no parsing is required, a parser can skip the parsing process by returning true in this function.
        isValidOutput in class FormatParser
        o - the value.
        true, if the given value is already an instance of date.