Package org.eclipse.birt.core.data

# Class ExpressionUtil

java.lang.Object
org.eclipse.birt.core.data.ExpressionUtil

public final class ExpressionUtil extends Object
This class help to manipulate expressions.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DATA_INDICATOR`
prefix for column bindings in Cube
`static final String`
`DATASET_ROW_INDICATOR`
prefix for dataset row
`static final String`
`DIMENSION_INDICATOR`
prefix for dimension
`static String`
`EXPRESSION_VALUE_SUFFIX`
`static final String`
`MEASURE_INDICATOR`
prefix for measure
`static final String`
`PARAMETER_INDICATOR`
prefix for parameter
`static final String`
`ROW_INDICATOR`
prefix for row
`static final String`
`VARIABLE_INDICATOR`
prefix for variable

## Constructor Summary

Constructors
Constructor
Description
`ExpressionUtil()`

## Method Summary

Modifier and Type
Method
Description
`static String`
`createDataSetRowExpression(String rowName)`
Return a dataSetRow expression text according to given row name.
`static String`
`createJSDataExpression(String dataName)`
Return a JS data expression text according to given data name.
`static String`
`createJSDataSetRowExpression(String rowName)`
Return a JS dataSetRow expression text according to given row name.
`static String`
`createJSDimensionExpression(String dimensionName, String levelName)`
Return a JS dimension expression text according to given dimension and measure name.By default it is reference to "ID" attribute of that level.
`static String`
`createJSDimensionExpression(String dimensionName, String levelName, String attributeName)`
Return a JS dimension expression text according to given dimension and measure name.
`static String`
`createJSMeasureExpression(String measureName)`
Return a JS measure expression text according to given measure name.
`static String`
`createJSParameterExpression(String parameterName)`
Return a JS parameter expression text according to given row name.
`static String`
`createJSParameterValueExpression(String parameterName)`
Return a JavaScript parameter value according to an expression.
`static String`
`createJSRowExpression(String rowName)`
Return a JS row expression text according to given row name.
`static String`
`createRowExpression(int index)`
Deprecated.
`static String`
`createRowExpression(String rowName)`
Return a row expression text according to given row name.
`static List<IColumnBinding>`
`extractColumnExpressions(String oldExpression)`
Extract all column expression info
`static List<IColumnBinding>`
`extractColumnExpressions(String oldExpression, boolean mode)`
Deprecated.
use `extractColumnExpressions( String, String )` instead
`static List<IColumnBinding>`
`extractColumnExpressions(String oldExpression, String indicator)`
Extract all column expression info
`static String`
`generateConstantExpr(String input, int dataType)`
Generate a Javascript constant expression by user input string and target BIRT data type.
`static Set<String>`
`getAllReferencedMeasures(String expr)`
`static IColumnBinding`
`getColumnBinding(String oldExpression)`
Return an IColumnBinding instance according to given oldExpression.
`static String`
`getColumnBindingName(String oldExpression)`
Get the simplest column binding name.
`static String`
`getColumnName(String oldExpression)`
Get the simplest column binding name.
`static String`
`getDataSetNameWithoutPrefix(String fullDataSetName)`
Gets the data set name with the given full name.
`static Set<IDimLevel>`
`getReferencedDimLevel(String expr)`
`static String`
`getReferencedMeasure(String expr)`
Deprecated.
replaced by getAllReferencedMeasures
`static String[]`
`getSourceDataSetNames(String jointColumName)`
`static boolean`
`hasAggregation(String expression)`
whethter the expression has aggregation
`static boolean`
`isScalarParamReference(String expression)`
whether the exression is report paramter reference.The pattern should like params["aa"].if yes, return true.
`static String`
`replaceParameterName(String expr, String paramOldName, String paramNewName)`
`static void`
`resetSuffix()`
When tests repeat, the static suffix has a wrong value.
`static String`
`toNewExpression(String oldExpression)`
Translate the old expression with "row" as indicator to new expression using "dataSetRow" as indicator.
`static String`
`updateParentQueryReferenceExpression(String oldExpression, boolean isParameterBinding)`
Translate the old expression with "rows" as parent query indicator to new expression using "row._outer" as parent query indicator.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ROW_INDICATOR

public static final String ROW_INDICATOR
prefix for row

See Also:
  - Constant Field Values

### DATASET_ROW_INDICATOR

public static final String DATASET_ROW_INDICATOR
prefix for dataset row

See Also:
  - Constant Field Values

### PARAMETER_INDICATOR

public static final String PARAMETER_INDICATOR
prefix for parameter

See Also:
  - Constant Field Values

### MEASURE_INDICATOR

public static final String MEASURE_INDICATOR
prefix for measure

See Also:
  - Constant Field Values

### DIMENSION_INDICATOR

public static final String DIMENSION_INDICATOR
prefix for dimension

See Also:
  - Constant Field Values

### DATA_INDICATOR

public static final String DATA_INDICATOR
prefix for column bindings in Cube

See Also:
  - Constant Field Values

### EXPRESSION_VALUE_SUFFIX

public static String EXPRESSION_VALUE_SUFFIX

### VARIABLE_INDICATOR

public static final String VARIABLE_INDICATOR
prefix for variable

See Also:
  - Constant Field Values

## Constructor Details

### ExpressionUtil

public ExpressionUtil()

## Method Details

### createRowExpression

public static String createRowExpression(String rowName)
Return a row expression text according to given row name.

Parameters:
  `rowName` -
Returns:

### resetSuffix

public static void resetSuffix()
When tests repeat, the static suffix has a wrong value. This method enables tests to reset the suffix.

### createDataSetRowExpression

public static String createDataSetRowExpression(String rowName)
Return a dataSetRow expression text according to given row name.

Parameters:
  `rowName` -
Returns:

### createJSRowExpression

public static String createJSRowExpression(String rowName)
Return a JS row expression text according to given row name.

Parameters:
  `rowName` -
Returns:

### createJSMeasureExpression

public static String createJSMeasureExpression(String measureName)
Return a JS measure expression text according to given measure name.

Parameters:
  `measureName` -
Returns:

### createJSDataExpression

public static String createJSDataExpression(String dataName)
Return a JS data expression text according to given data name.

Parameters:
  `dataName` -
Returns:

### createJSDimensionExpression

public static String createJSDimensionExpression(String dimensionName, String levelName)
Return a JS dimension expression text according to given dimension and measure name.By default it is reference to "ID" attribute of that level.

Parameters:
  `dimensionName` -
  `levelName` -
Returns:

### createJSDimensionExpression

public static String createJSDimensionExpression(String dimensionName, String levelName, String attributeName)
Return a JS dimension expression text according to given dimension and measure name.

Parameters:
  `dimensionName` -
  `levelName` -
  `attributeName` -
Returns:

### createJSDataSetRowExpression

public static String createJSDataSetRowExpression(String rowName)
Return a JS dataSetRow expression text according to given row name.

Parameters:
  `rowName` -
Returns:

### createJSParameterExpression

public static String createJSParameterExpression(String parameterName)
Return a JS parameter expression text according to given row name.

Parameters:
  `rowName` -
Returns:

### createJSParameterValueExpression

public static String createJSParameterValueExpression(String parameterName)
Return a JavaScript parameter value according to an expression.

Parameters:
  `expression` -
Returns:

### createRowExpression

@Deprecated public static String createRowExpression(int index)
Deprecated.
Return a row expression text according to given row index, which is 1-based.

Parameters:
  `index` -
Returns:

### extractColumnExpressions

public static List<IColumnBinding> extractColumnExpressions(String oldExpression) throws BirtException
Extract all column expression info

Parameters:
  `oldExpression` -
Returns:
Throws:
  `BirtException`

### getColumnBindingName

public static String getColumnBindingName(String oldExpression) throws BirtException
Get the simplest column binding name. Such as row["col1"] pattern, we will return the column name "col1"

Parameters:
  `oldExpression` -
Returns:
Throws:
  `BirtException`

### getColumnName

public static String getColumnName(String oldExpression) throws BirtException
Get the simplest column binding name. Such as dataSetRow["col1"] pattern, we will return the column name "col1"

Parameters:
  `oldExpression` -
Returns:
Throws:
  `BirtException`

### extractColumnExpressions

@Deprecated public static List<IColumnBinding> extractColumnExpressions(String oldExpression, boolean mode) throws BirtException
Deprecated.
use `extractColumnExpressions( String, String )` instead
Extract all column expression info

Parameters:
  `oldExpression` -
  `mode` - if true, it means to compile the "row" expression.else extract "dataSetRow" expression
Returns:
Throws:
  `BirtException`

### extractColumnExpressions

public static List<IColumnBinding> extractColumnExpressions(String oldExpression, String indicator) throws BirtException
Extract all column expression info

Parameters:
  `oldExpression` -
  `mode` - if true, it means to compile the "row" expression.else extract "dataSetRow" expression
Returns:
Throws:
  `BirtException`

### hasAggregation

public static boolean hasAggregation(String expression)
whethter the expression has aggregation

Parameters:
  `oldExpression` -
Returns:
Throws:
  `BirtException`

### getColumnBinding

public static IColumnBinding getColumnBinding(String oldExpression)
Return an IColumnBinding instance according to given oldExpression.

Parameters:
  `oldExpression` -
Returns:

### toNewExpression

public static String toNewExpression(String oldExpression)
Translate the old expression with "row" as indicator to new expression using "dataSetRow" as indicator.

Parameters:
  `oldExpression` -
Returns:

### updateParentQueryReferenceExpression

public static String updateParentQueryReferenceExpression(String oldExpression, boolean isParameterBinding)
Translate the old expression with "rows" as parent query indicator to new expression using "row._outer" as parent query indicator.

Parameters:
  `oldExpression` -
  `isParameterBinding` -
Returns:

### isScalarParamReference

public static boolean isScalarParamReference(String expression)
whether the exression is report paramter reference.The pattern should like params["aa"].if yes, return true. else return false;

Parameters:
  `expression` -

### getSourceDataSetNames

public static String[] getSourceDataSetNames(String jointColumName)

Parameters:
  `jointColumName` -
Returns:

### getDataSetNameWithoutPrefix

public static String getDataSetNameWithoutPrefix(String fullDataSetName)
Gets the data set name with the given full name. The full name may contain the library namespace.

For example,

- "dataSet1" is extracted from "new_library.dataSet1"

Parameters:
  `fullDataSetName` - the data set
Returns:
  the name

### getReferencedDimLevel

public static Set<IDimLevel> getReferencedDimLevel(String expr) throws CoreException

Parameters:
  `expr` -
Returns:
Throws:
  `CoreException`

### getReferencedMeasure

@Deprecated public static String getReferencedMeasure(String expr) throws CoreException
Deprecated.
replaced by getAllReferencedMeasures

Parameters:
  `expr` -
Returns:
  get the first measure name in this expression
Throws:
  `CoreException`

### getAllReferencedMeasures

public static Set<String> getAllReferencedMeasures(String expr) throws CoreException

Parameters:
  `expr` -
Returns:
  get the referenced measure name in this expression
Throws:
  `CoreException`

### replaceParameterName

public static String replaceParameterName(String expr, String paramOldName, String paramNewName)

Parameters:
  `expr` -
  `paramOldName` -
  `paramNewName` -
Returns:

### generateConstantExpr

public static String generateConstantExpr(String input, int dataType) throws BirtException
Generate a Javascript constant expression by user input string and target BIRT data type.

Parameters:
  `input` - user input string.
  `dataType` - target BIRT data type. available values defined in `org.eclipse.birt.core.data.DataType`
Returns:
  generated Javascript constant expression text