public class FormulaField extends Field implements com.inet.report.ReferenceHolder, Validatable, com.inet.report.formula.IFormulaData
FormulaField
to the fields set use method Fields.addFormulaField(String,String,int)
in
class Fields
. Note that the usableness of the formula field have to set explicitly at
creation time or with method setFormulaType(int)
.
Modifier and Type | Field and Description |
---|---|
static int |
BEFORE_READING_RECORDS
Constant value of evaluation time.
|
static int |
FORMULA_GROUP_SELECTION
group selection formula
|
static int |
FORMULA_PROPERTY
property formula
|
static int |
FORMULA_RECORD_SELECTION
record selection formula
|
static int |
FORMULA_USER
user defined formula
|
static int |
SYNTAX_BASIC
Formula in Basic Syntax
|
static int |
SYNTAX_CRYSTAL
Formula in Crystal Syntax
|
static int |
TREAT_NULL_AS_NULL
Sets the formula calculation to tolerate null values, if possible.
|
static int |
TREAT_NULL_BY_DEFAULT
Sets the formula calculation to replace null values by the default values of the same type.
|
static int |
TREAT_NULL_BY_EXCEPTION
Sets the formula calculation to always interrupt if there is any null value.
|
static int |
UNSPECIFIED_EVALUATE_TIME
Constant value of evaluation time.
|
static int |
WHILE_PRINTING_RECORDS
Constant value of evaluation time.
|
static int |
WHILE_READING_RECORDS
Constant value of evaluation time.
|
BINARY, BOOLEAN, CURRENCY, CURSOR, DATABASE_FIELD, DATE, DATETIME, FORMULA_FIELD, GROUP_NAME_FIELD, NUMBER, PARAMETER_FIELD, SORT_FIELD, SPECIAL_FIELD, SQL_FIELD, STRING, SUMMARY_FIELD, TIME, UNKNOWN
Modifier and Type | Method and Description |
---|---|
void |
checkContext()
Checks the evaluation time of the current formula
|
static int |
checkFormula(java.lang.String formula,
boolean basic,
Engine engine)
Checks the syntax and the type of the formula and returns the return type of the formula if formula has no errors.
|
static int |
checkFormula(java.lang.String formula,
boolean basic,
Engine engine,
Field currentField,
java.lang.Object defaultAttribute)
Checks the syntax and the type of the formula and returns the return type of the formula if formula has no errors.
|
static int |
checkFormula(java.lang.String formula,
boolean basic,
Engine engine,
Field currentField,
java.lang.Object defaultAttribute,
int formulaType)
Checks the syntax and the type of the formula and returns the return type of the formula if formula has no errors.
|
static int |
checkFormula(java.lang.String formula,
boolean basic,
Engine engine,
Field currentField,
java.lang.Object defaultAttribute,
int formulaType,
int nullBehavior)
Checks the syntax and the type of the formula and returns the return type of the formula if formula has no errors.
|
int |
checkFormula(java.lang.String formula,
boolean basic,
int nullBehavior)
Checks a formula as if it was set to to this formula fields.
|
void |
clearLocalVariables()
Resets the local variables of this field
|
Field |
duplicate(java.lang.String name)
Duplicates this field with all its settings and returns the created Field with the given name.
|
Field |
getCurrentField()
This field references the current report field, which contains this formula.
|
int |
getEvaluateTime()
Returns the lowest theoretically possible evaluation time this formula can have.
|
int |
getEvaluateTimeReal()
Returns the time of evaluation of this formula that is actually used at runtime.
|
java.lang.String |
getFormula()
Returns the value of the property 'formula text'.
|
int |
getFormulaType()
Returns the formula type, i.e. whether the formula is a record selection, group selection, property, or user formula
|
com.inet.report.formula.Variables |
getLocalVariables()
Returns all local variables of this field
|
int |
getNullBehavior()
Returns the null behavoir constant which was set for this formula field.
|
int |
getSyntax()
Returns the syntax for this formula.
|
java.util.Set<java.lang.String> |
getTranslationKeys()
Returns a set of all translation keys used in the formula described by this field.
|
int |
getValueType()
Returns the value type (or return type) of the field.
|
static boolean |
isEmpty(java.lang.String formula,
boolean basic,
Engine engine)
Checks the syntax of the formula and returns
true if the formula (body without layout) is empty. |
boolean |
isEmpty()
Checks the syntax of the formula and returns
true if the formula (body without layout) is empty. |
static boolean |
isEmpty(java.lang.String formula,
boolean basic,
Engine engine,
Field currentField,
java.lang.Object defaultAttribute)
Checks the syntax of the formula and returns
true if the formula (body without layout) is empty. |
java.lang.String |
paramString()
Returns a prettified output of this field's name and type.
|
void |
setCurrentField(Field currentField)
This field references the current report field, which contains this formula.
|
void |
setFormula(java.lang.String formula)
Sets formula text to this element and parses the formula.
|
void |
setFormulaType(int type)
Sets the formula type.
|
void |
setName(java.lang.String name)
Sets the name of the formula field.
|
void |
setNullBehavior(int nullBehavior)
Sets the null behavoir constant.
|
void |
setSyntax(int syntax)
Set the syntax for this formula.
|
boolean |
usesSummaryFields()
Returns true, if this formula field references to a summary field and is referenced by a
summary field - either directly or indirectly
|
Validity |
validate()
Check if the object is valid and returns the state and details of possible errors.
|
checkNameExists, extractReference, getField, getGroup, getName, getPlaceholderName, getRefName, getType, indexOf, setField, setGroup, setValueType, trimAwayBrackets
isDOMParser, parseDOM, parseElement, parseEndElement, parseText
public static final int FORMULA_USER
public static final int FORMULA_RECORD_SELECTION
public static final int FORMULA_GROUP_SELECTION
public static final int FORMULA_PROPERTY
public static final int TREAT_NULL_AS_NULL
public static final int TREAT_NULL_BY_DEFAULT
public static final int TREAT_NULL_BY_EXCEPTION
public static final int UNSPECIFIED_EVALUATE_TIME
public static final int BEFORE_READING_RECORDS
public static final int WHILE_READING_RECORDS
public static final int WHILE_PRINTING_RECORDS
public static final int SYNTAX_CRYSTAL
public static final int SYNTAX_BASIC
public void setName(java.lang.String name)
public java.lang.String getFormula()
setSyntax(int)
public void setFormula(java.lang.String formula)
setSyntax(int)
before calling
this function.formula
- the new formulasetSyntax(int)
,
getSyntax()
,
getFormula()
public int getSyntax()
SYNTAX_CRYSTAL
,
SYNTAX_BASIC
public void setSyntax(int syntax)
syntax
- the syntax to use for this formulajava.lang.IllegalArgumentException
- If the syntax is not one of the valid types.SYNTAX_CRYSTAL
,
SYNTAX_BASIC
public int getFormulaType()
FORMULA_USER
,
FORMULA_RECORD_SELECTION
,
FORMULA_GROUP_SELECTION
,
FORMULA_PROPERTY
public void setFormulaType(int type)
type
- The type of the formula.java.lang.IllegalArgumentException
- is thrown if type
is not one of FORMULA_USER, FORMULA_RECORD_SELECTION, FORMULA_GROUP_SELECTION and FORMULA_PROPERTY.FORMULA_USER
,
FORMULA_RECORD_SELECTION
,
FORMULA_GROUP_SELECTION
,
FORMULA_PROPERTY
public static int checkFormula(java.lang.String formula, boolean basic, Engine engine) throws ReportException
formula
- The formula as stringbasic
- true
if formula has basic syntax, else if formula has crystal syntax false
engine
- The engine that should evaluate the formulaReportException
- will thrown if the syntax or the type of the formula or its expressions and statements is not correct.public static int checkFormula(java.lang.String formula, boolean basic, Engine engine, Field currentField, java.lang.Object defaultAttribute) throws ReportException
formula
- The formula as stringbasic
- true
if formula has basic syntax, else if formula has crystal syntax false
engine
- The engine that should evaluate the formulacurrentField
- If checked formula is a formula which calculates the property value of a field element then it is possible
to use the value of the field in your formula. Therefore use constant "currentFieldValue" in formula
.
The field of the field element is needed to get the value from.defaultAttribute
- When processing formula which calculates the property value of an element in report,
then it is possible to use the constant value of the property in your formulas. Therefore the current value of the
property is needed as default attribute.ReportException
- will thrown if the syntax or the type of the formula or its expressions and statements is not correct.public static int checkFormula(java.lang.String formula, boolean basic, Engine engine, Field currentField, java.lang.Object defaultAttribute, int formulaType) throws ReportException
formula
- The formula as stringbasic
- true
if formula has basic syntax, else if formula has crystal syntax false
engine
- The engine that should evaluate the formulacurrentField
- If checked formula is a formula which calculates the property value of a field element then it is possible
to use the value of the field in your formula. Therefore use constant "currentFieldValue" in formula
.
The field of the field element is needed to get the value from.defaultAttribute
- When processing formula which calculates the property value of an element in report,
then it is possible to use the constant value of the property in your formulas. Therefore the current value of the
property is needed as default attribute.formulaType
- The formula's type: FORMULA_USER, FORMULA_RECORD_SELECTION, FORMULA_GROUP_SELECTION, or FORMULA_PROPERTYReportException
- will thrown if the syntax or the type of the formula or its expressions and statements is not correct.public static int checkFormula(java.lang.String formula, boolean basic, Engine engine, Field currentField, java.lang.Object defaultAttribute, int formulaType, int nullBehavior) throws ReportException
formula
- The formula as stringbasic
- true
if formula has basic syntax, else if formula has crystal syntax false
engine
- The engine that should evaluate the formulacurrentField
- If checked formula is a formula which calculates the property value of a field element then it is possible
to use the value of the field in your formula. Therefore use constant "currentFieldValue" in formula
.
The field of the field element is needed to get the value from.defaultAttribute
- When processing formula which calculates the property value of an element in report,
then it is possible to use the constant value of the property in your formulas. Therefore the current value of the
property is needed as default attribute.formulaType
- The formula's type: FORMULA_USER, FORMULA_RECORD_SELECTION, FORMULA_GROUP_SELECTION, or FORMULA_PROPERTYnullBehavior
- The null behavior constant: TREAT_NULL_AS_NULL
, TREAT_NULL_BY_DEFAULT
, TREAT_NULL_BY_EXCEPTION
ReportException
- will thrown if the syntax or the type of the formula or its expressions and statements is not correct.public int checkFormula(java.lang.String formula, boolean basic, int nullBehavior) throws ReportException
formula
- the formula to checkbasic
- true
if formula has basic syntax, else if formula has crystal syntax false
nullBehavior
- The null behavior constant: TREAT_NULL_AS_NULL
, TREAT_NULL_BY_DEFAULT
, TREAT_NULL_BY_EXCEPTION
ReportException
- thrown if the formula causes any errorpublic int getValueType()
getValueType
in class Field
Field.NUMBER
,
Field.CURRENCY
,
Field.BOOLEAN
,
Field.DATE
,
Field.TIME
,
Field.STRING
,
Field.DATETIME
public void checkContext() throws ReportException
ReportException
- will be thrown if the formula cannot be executed at the requested timepublic static boolean isEmpty(java.lang.String formula, boolean basic, Engine engine) throws ReportException
true
if the formula (body without layout) is empty.formula
- The formula as stringbasic
- true
if formula has basic syntax, else if formula has crystal syntax false
engine
- The engine that should evaluate the formulatrue
if formula is empty (except layout like blanks, line feeds, comments) else false
ReportException
- will thrown if the syntax or the type of the formula or its expressions and statements is not correct.public boolean isEmpty()
true
if the formula (body without layout) is empty.true
if formula is empty (except layout like blanks, line feeds, comments) else false
public static boolean isEmpty(java.lang.String formula, boolean basic, Engine engine, Field currentField, java.lang.Object defaultAttribute) throws ReportException
true
if the formula (body without layout) is empty.formula
- The formula as stringbasic
- true
if formula has basic syntax, else if formula has crystal syntax false
engine
- The engine that should evaluate the formulacurrentField
- Field to be viewed as the "currentField" of the report, specifically for the "CurrentField" function.defaultAttribute
- Attribute to be viewed as the "defaultAttribute", specifically for the "DefaultAttribute" function.true
if formula is empty (except layout like blanks, line feeds, comments) else false
ReportException
- will thrown if the syntax or the type of the formula or its expressions and statements is not correct.public java.lang.String paramString()
paramString
in class Field
public int getEvaluateTimeReal() throws ReportException
BEFORE_READING_RECORDS
,
WHILE_PRINTING_RECORDS
, or WHILE_READING_RECORDS
.ReportException
- If parsing the formula encounters errors.BEFORE_READING_RECORDS
,
WHILE_READING_RECORDS
,
WHILE_PRINTING_RECORDS
,
getEvaluateTime()
public int getEvaluateTime() throws ReportException
BEFORE_READING_RECORDS
,
WHILE_PRINTING_RECORDS
, or WHILE_READING_RECORDS
.ReportException
- If parsing the formula causes any errorsBEFORE_READING_RECORDS
,
WHILE_READING_RECORDS
,
WHILE_PRINTING_RECORDS
,
getEvaluateTimeReal(boolean)
public Field duplicate(java.lang.String name)
public int getNullBehavior()
TREAT_NULL_AS_NULL
,
TREAT_NULL_BY_DEFAULT
,
TREAT_NULL_BY_EXCEPTION
public void setNullBehavior(int nullBehavior)
nullBehavior
- the behavior constantTREAT_NULL_AS_NULL
,
TREAT_NULL_BY_DEFAULT
,
TREAT_NULL_BY_EXCEPTION
public boolean usesSummaryFields()
public java.util.Set<java.lang.String> getTranslationKeys()
public Validity validate()
validate
in interface Validatable
public com.inet.report.formula.Variables getLocalVariables()
public void clearLocalVariables()
public void setCurrentField(Field currentField)
currentField
- field to set as "current report field"public Field getCurrentField()
Copyright © 1999-2020 by i-net software GmbH