Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jet.api
Class FormulaInfo

    java.lang.Object
      jet.api.FormulaInfo

    public class FormulaInfo

extends java.lang.Object

The class defines a JReport Formula object. Formulas are objects that are computed at runtime, which allow you to manipulate field data by performing calculations on it. They control the data that will be displayed, and can even create new data not directly available from the database. A formula is a symbolic statement of the manipulations that are to be performed on certain data before it is printed onto your report. For example, if your report contains an @Sales field and an @Cost field, and you want to create an @GrossProfit formula, you can designate its value as @Sales - @Cost. @GrossProfit is a simple formula that tells JReport to subtract the value of the @Cost field from the value of the @Sales field, and then to print the result. Formulas can be used to calculate numeric values, compare one value to another and select alternative actions based on the comparison. Also, they can be used to join multiple text strings into a single string. In general, formulas can be used to:

- calculate information you cannot directly obtain from database data fields.
- compare data.
- join text with data.
- convert data from one form to another.
- enhance formatting options with text strings.
- do other things that customize your reports.

Meanwhile, in JReport, there is a type of formulas which are refer to as constant level formulas. These kind of formulas never refer to a DBField, page level special fields (the value of the special field is ready at the time when the report result is generated), or other constant level formulas. The allowed constants that can be referred to by the formulas are: parameters, the special field User Name, constant values such as "aaa", and the combination of the above three.

Notes:

- You should have some knowledge of the formula syntax before you can successfully compose a formula with no errors. To learn the formula syntax, refer to topics in User Guide#Formula syntax.
- If you refer to any field in the formula, the reference name for that field will be prefixed with an @ sign. If the field name contains spaces, the reference name in formula will be quoted with double-quotation marks (""). For example, if the field name is Customer Name, then the reference name will be @"Customer Name".
- When formulas refer display names or mapping names, the names should not contain any of below characters if the names are not quoted by double-quotation marks "":
  "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "+", "=", "{", "}", "[", "]", "|", "\\", ":", ";", "\", " ' ", "<", ",", ">", ".", "?", "/"
  Examples:
  Expression @Customer#; will cause a syntax error. But @"Customer#" is correct. If a field has the display name Category.Measure, when adding it to a formula, quote it as "Category.Measure" or "Category"."Measure".
- The number of the "if-else" statements in a formula is limited to 190. When this number is reached, you should use the "select-case" statement instead.

  Constructor Summary
  `FormulaInfo()` Constructor.
  `FormulaInfo(java.lang.String name, java.lang.String desc, java.lang.String expression)` Constructor.

  Method Summary
  `java.lang.String` | `getDescription()` Gets the formula's description.
  `java.lang.String` | `getExpression()` Gets the formula expression.
  `java.lang.String` | `getName()` Gets the formula's mapping name.
  `void` | `setDescription(java.lang.String desc)` Sets the formula's description.
  `void` | `setExpression(java.lang.String expression)` Sets the formula expression.
  `void` | `setName(java.lang.String name)` Sets the formula's mapping name.

  Methods inherited from class java.lang.Object
  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  Constructor Detail

  ### FormulaInfo

      public FormulaInfo()

    Constructor. Creates the formula definition object.

  ### FormulaInfo

      public FormulaInfo(java.lang.String name,
                         java.lang.String desc,
                         java.lang.String expression)

    Constructor. Creates the formula definition object.

    Parameters:
      `name` - The mapping name of the formula.
      `desc` - The description of the formula.
      `expression` - The String format of the formula's expression.

  Method Detail

  ### getName

      public java.lang.String getName()

    Gets the formula's mapping name.

    Returns:
      formula's mapping name.

  ### setName

      public void setName(java.lang.String name)

    Sets the formula's mapping name.

    Parameters:
      `name` - Formula's mapping name.

  ### getDescription

      public java.lang.String getDescription()

    Gets the formula's description.

    Returns:
      formula description text.

  ### setDescription

      public void setDescription(java.lang.String desc)

    Sets the formula's description.

    Parameters:
      `desc` - Formula description text.

  ### getExpression

      public java.lang.String getExpression()

    Gets the formula expression.

    Returns:
      formula expression text.

  ### setExpression

      public void setExpression(java.lang.String expression)

    Sets the formula expression.

    Parameters:
      `expression` - The formula's expression.

  Overview | Package | Class | Tree | Deprecated | Index | Help
  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD