Package org.eclipse.birt.core.data
Class ExpressionUtil
java.lang.Object
org.eclipse.birt.core.data.ExpressionUtil
This class help to manipulate expressions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
prefix for column bindings in Cubestatic final String
prefix for dataset rowstatic final String
prefix for dimensionstatic String
static final String
prefix for measurestatic final String
prefix for parameterstatic final String
prefix for rowstatic final String
prefix for variable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 infostatic List<IColumnBinding>
extractColumnExpressions
(String oldExpression, boolean mode) Deprecated.static List<IColumnBinding>
extractColumnExpressions
(String oldExpression, String indicator) Extract all column expression infostatic String
generateConstantExpr
(String input, int dataType) Generate a Javascript constant expression by user input string and target BIRT data type.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.getReferencedDimLevel
(String expr) static String
getReferencedMeasure
(String expr) Deprecated.replaced by getAllReferencedMeasuresstatic String[]
getSourceDataSetNames
(String jointColumName) static boolean
hasAggregation
(String expression) whethter the expression has aggregationstatic 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
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.
-
Field Details
-
ROW_INDICATOR
prefix for row- See Also:
-
DATASET_ROW_INDICATOR
prefix for dataset row- See Also:
-
PARAMETER_INDICATOR
prefix for parameter- See Also:
-
MEASURE_INDICATOR
prefix for measure- See Also:
-
DIMENSION_INDICATOR
prefix for dimension- See Also:
-
DATA_INDICATOR
prefix for column bindings in Cube- See Also:
-
EXPRESSION_VALUE_SUFFIX
-
VARIABLE_INDICATOR
prefix for variable- See Also:
-
-
Constructor Details
-
ExpressionUtil
public ExpressionUtil()
-
-
Method Details
-
createRowExpression
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
Return a dataSetRow expression text according to given row name.- Parameters:
rowName
-- Returns:
-
createJSRowExpression
Return a JS row expression text according to given row name.- Parameters:
rowName
-- Returns:
-
createJSMeasureExpression
Return a JS measure expression text according to given measure name.- Parameters:
measureName
-- Returns:
-
createJSDataExpression
Return a JS data expression text according to given data name.- Parameters:
dataName
-- Returns:
-
createJSDimensionExpression
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
Return a JS dataSetRow expression text according to given row name.- Parameters:
rowName
-- Returns:
-
createJSParameterExpression
Return a JS parameter expression text according to given row name.- Parameters:
rowName
-- Returns:
-
createJSParameterValueExpression
Return a JavaScript parameter value according to an expression.- Parameters:
expression
-- Returns:
-
createRowExpression
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
Get the simplest column binding name. Such as row["col1"] pattern, we will return the column name "col1"- Parameters:
oldExpression
-- Returns:
- Throws:
BirtException
-
getColumnName
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.useextractColumnExpressions( String, String )
insteadExtract 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
whethter the expression has aggregation- Parameters:
oldExpression
-- Returns:
- Throws:
BirtException
-
getColumnBinding
Return an IColumnBinding instance according to given oldExpression.- Parameters:
oldExpression
-- Returns:
-
toNewExpression
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
whether the exression is report paramter reference.The pattern should like params["aa"].if yes, return true. else return false;- Parameters:
expression
-
-
getSourceDataSetNames
- Parameters:
jointColumName
-- Returns:
-
getDataSetNameWithoutPrefix
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
- Parameters:
expr
-- Returns:
- Throws:
CoreException
-
getReferencedMeasure
Deprecated.replaced by getAllReferencedMeasures- Parameters:
expr
-- Returns:
- get the first measure name in this expression
- Throws:
CoreException
-
getAllReferencedMeasures
- Parameters:
expr
-- Returns:
- get the referenced measure name in this expression
- Throws:
CoreException
-
replaceParameterName
- Parameters:
expr
-paramOldName
-paramNewName
-- Returns:
-
generateConstantExpr
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 inorg.eclipse.birt.core.data.DataType
- Returns:
- generated Javascript constant expression text
- Throws:
BIRTException
BirtException
-
extractColumnExpressions( String, String )
instead