Class DefaultValue

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class DefaultValue
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    Holder for a PromptField's default value and its description. If the default value does not have a description, getDescription() will return null. The default value's "value" may be null.
    Since:
    7.6
    See Also:
    PromptField, Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        DefaultValue​(java.lang.Object value, java.lang.String description)
      Creates a default value with field value type set as UNKNOWN
        DefaultValue​(java.lang.Object value, java.lang.String description, int type)
      Creates a DefaultValue with the given value and description.
      protected DefaultValue​(java.lang.String description, int type)
      internal constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      static DefaultValue createBinaryDefaultValue​(java.lang.String value, java.lang.String description)
      Creates and returns a default value of value type Field.BINARY.
      static DefaultValue createDefaultValueFromFormula​(java.lang.String value, java.lang.String description, int valueType, Engine engine)
      Creates and returns a default value by parsing the given value string as a CC formula.
      static DefaultValue createDefaultValueFromFormula​(java.lang.String value, java.lang.String description, Engine engine)
      Creates and returns a default value by parsing the given value string as a CC formula.
      static com.inet.report.FormulaDefaultValue createFormulaFieldDefaultValueFromFormula​(FormulaField formulaField, java.lang.String description, int valueType, Engine engine)
      creates and returns a default value based on the formula given.
      boolean equals​(java.lang.Object obj)
      java.lang.String getDescription()
      Returns the description of this default value.
      int getType()
      Returns the value type set in the constructor for this default value
      java.lang.Object getValue()
      Returns the value of this default value.
      int hashCode()
      void setDescription​(java.lang.String description)
      Sets the description of this default value.
      void setValue​(java.lang.Object value)
      Sets the value of this default value.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultValue

        protected DefaultValue​(java.lang.String description,
                               int type)
        internal constructor
        Parameters:
        description - description of default value
        type - value type of default value
        Since:
        11.0
      • DefaultValue

        public DefaultValue​(java.lang.Object value,
                            java.lang.String description,
                            int type)
        Creates a DefaultValue with the given value and description. The object must be of a certain type, depending on the value type of the Prompt Field:
        • NUMBER : java.lang.Double
        • CURRENCY : java.lang.Double
        • BOOLEAN : java.lang.Boolean
        • DATE : java.sql.Date
        • TIME : java.sql.Time
        • DATETIME : java.sql.Timestamp
        • STRING : java.lang.String
        • Range : com.inet.report.FormulaRange
        Parameters:
        value - Value of the default value
        description - Description of the default value, can be null if there is no description
        type - field type of the prompt field to which this default value belongs
        Throws:
        java.lang.IllegalArgumentException - if the field type does not match the object type or if the field type is unknown
        Since:
        7.6
        See Also:
        Field.NUMBER, Field.STRING, Field.DATETIME, Field.DATE, Field.BOOLEAN, Field.CURRENCY, Field.BINARY, Field.TIME
      • DefaultValue

        public DefaultValue​(java.lang.Object value,
                            java.lang.String description)
        Creates a default value with field value type set as UNKNOWN
        Parameters:
        value - value of the default value
        description - description of the default value, may be null
        Since:
        7.6
        See Also:
        DefaultValue(Object, String, int)
    • Method Detail

      • createDefaultValueFromFormula

        public static DefaultValue createDefaultValueFromFormula​(java.lang.String value,
                                                                 java.lang.String description,
                                                                 Engine engine)
                                                          throws ReportException
        Creates and returns a default value by parsing the given value string as a CC formula.
        Parameters:
        value - value as formula syntax
        description - description of the default value, can be null
        engine - engine used to parse the formula
        Returns:
        created default value
        Throws:
        ReportException - if an error occurs while parsing the formula
        Since:
        7.6
      • createDefaultValueFromFormula

        public static DefaultValue createDefaultValueFromFormula​(java.lang.String value,
                                                                 java.lang.String description,
                                                                 int valueType,
                                                                 Engine engine)
                                                          throws ReportException
        Creates and returns a default value by parsing the given value string as a CC formula. Checks to make sure the formula's value type is the same as the value type given.
        Parameters:
        value - value as formula syntax
        description - description of the default value, can be null
        valueType - value type of the default value to be created.
        engine - engine used to parse the formula
        Returns:
        created default value
        Throws:
        ReportException - if an error occurs while parsing the formula
        Since:
        7.6
      • createFormulaFieldDefaultValueFromFormula

        public static com.inet.report.FormulaDefaultValue createFormulaFieldDefaultValueFromFormula​(FormulaField formulaField,
                                                                                                    java.lang.String description,
                                                                                                    int valueType,
                                                                                                    Engine engine)
        creates and returns a default value based on the formula given. When a prompt is created with FormulaDefaultValues, the values are parsed at run-time, making it possible to have dynamically created yet "static" default values
        Parameters:
        formulaField - formula field to base default value on
        description - description of default value
        valueType - value type of default value
        engine - engine used to parse the formula
        Returns:
        created formula default value
        Since:
        11.0
      • createBinaryDefaultValue

        public static DefaultValue createBinaryDefaultValue​(java.lang.String value,
                                                            java.lang.String description)
        Creates and returns a default value of value type Field.BINARY. The value string is parsed as a Base64 encoded byte array.
        Parameters:
        value - Base64-encoded byte array as string
        description - description of the default value, can be null
        Returns:
        Created default value
        Since:
        7.6
      • getValue

        public java.lang.Object getValue()
        Returns the value of this default value. Can be null. The type of this value depends on the type of the prompt field.
        • NUMBER : java.lang.Double
        • CURRENCY : java.lang.Double
        • BOOLEAN : java.lang.Boolean
        • DATE : java.sql.Date
        • TIME : java.sql.Time
        • DATETIME : java.sql.Timestamp
        • STRING : java.lang.String
        • Range : com.inet.report.FormulaRange
        Returns:
        Value of this default value. Can be null.
        Since:
        7.6
        See Also:
        Field.getValueType()
      • setValue

        public void setValue​(java.lang.Object value)
        Sets the value of this default value. Can be null. The type of the object allowed to be set depends of the type of the prompt field.
        • NUMBER : java.lang.Double
        • CURRENCY : java.lang.Double
        • BOOLEAN : java.lang.Boolean
        • DATE : java.sql.Date
        • TIME : java.sql.Time
        • DATETIME : java.sql.Timestamp
        • STRING : java.lang.String
        • Range : com.inet.report.FormulaRange
        Parameters:
        value - value to set.
        Since:
        7.6
        See Also:
        Field.setValueType(int)
      • getDescription

        public java.lang.String getDescription()
        Returns the description of this default value. Will be null if there is no description for this DefaultValue.
        Returns:
        the description of this default value
        Since:
        7.6
      • setDescription

        public void setDescription​(java.lang.String description)
        Sets the description of this default value. The description can be set to null which means this default value has not description
        Parameters:
        description - description to set for this default value
        Since:
        7.6
      • getType

        public int getType()
        Returns the value type set in the constructor for this default value
        Returns:
        field value type of this default value.
        Since:
        7.6
        See Also:
        DefaultValue(Object, String, int)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException