Class DefaultValue

java.lang.Object
com.inet.report.DefaultValue
All Implemented Interfaces:
Serializable, Cloneable

public class DefaultValue extends Object implements Serializable, 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:
  • Constructor Details

    • DefaultValue

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

      public DefaultValue(Object value, 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:
      IllegalArgumentException - if the field type does not match the object type or if the field type is unknown
      Since:
      7.6
      See Also:
    • DefaultValue

      public DefaultValue(Object value, 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:
  • Method Details

    • createDefaultValueFromFormula

      public static DefaultValue createDefaultValueFromFormula(String value, 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(String value, 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, 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(String value, 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 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:
    • setValue

      public void setValue(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:
    • getDescription

      public 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(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:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

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