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.
        Returns:
        the formatter.
        Throws:
        NullPointerException - if the given format is null
      • setDateFormat

        public void setDateFormat​(DateFormat format)
        Sets the format for the filter.
        Parameters:
        format - The format.
        Throws:
        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
        Overrides:
        getValue in class FormatParser
        Parameters:
        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.
        Returns:
        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.

        Overrides:
        setNullValue in class FormatParser
        Parameters:
        nullvalue - the nullvalue returned when parsing failed.
        Throws:
        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.
        Overrides:
        isValidOutput in class FormatParser
        Parameters:
        o - the value.
        Returns:
        true, if the given value is already an instance of date.