Class ExpressionUtil

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

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

  • 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
      Throws:
      BIRTException
      BirtException