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 Stringprefix for column bindings in Cubestatic final Stringprefix for dataset rowstatic final Stringprefix for dimensionstatic Stringstatic final Stringprefix for measurestatic final Stringprefix for parameterstatic final Stringprefix for rowstatic final Stringprefix for variable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateDataSetRowExpression(String rowName) Return a dataSetRow expression text according to given row name.static StringcreateJSDataExpression(String dataName) Return a JS data expression text according to given data name.static StringcreateJSDataSetRowExpression(String rowName) Return a JS dataSetRow expression text according to given row name.static StringcreateJSDimensionExpression(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 StringcreateJSDimensionExpression(String dimensionName, String levelName, String attributeName) Return a JS dimension expression text according to given dimension and measure name.static StringcreateJSMeasureExpression(String measureName) Return a JS measure expression text according to given measure name.static StringcreateJSParameterExpression(String parameterName) Return a JS parameter expression text according to given row name.static StringcreateJSParameterValueExpression(String parameterName) Return a JavaScript parameter value according to an expression.static StringcreateJSRowExpression(String rowName) Return a JS row expression text according to given row name.static StringcreateRowExpression(int index) Deprecated.static StringcreateRowExpression(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 StringgenerateConstantExpr(String input, int dataType) Generate a Javascript constant expression by user input string and target BIRT data type.static IColumnBindinggetColumnBinding(String oldExpression) Return an IColumnBinding instance according to given oldExpression.static StringgetColumnBindingName(String oldExpression) Get the simplest column binding name.static StringgetColumnName(String oldExpression) Get the simplest column binding name.static StringgetDataSetNameWithoutPrefix(String fullDataSetName) Gets the data set name with the given full name.getReferencedDimLevel(String expr) static StringgetReferencedMeasure(String expr) Deprecated.replaced by getAllReferencedMeasuresstatic String[]getSourceDataSetNames(String jointColumName) static booleanhasAggregation(String expression) whethter the expression has aggregationstatic booleanisScalarParamReference(String expression) whether the exression is report paramter reference.The pattern should like params["aa"].if yes, return true.static StringreplaceParameterName(String expr, String paramOldName, String paramNewName) static voidWhen tests repeat, the static suffix has a wrong value.static StringtoNewExpression(String oldExpression) Translate the old expression with "row" as indicator to new expression using "dataSetRow" as indicator.static StringupdateParentQueryReferenceExpression(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:
BIRTExceptionBirtException
-
extractColumnExpressions( String, String )instead