Class TLcdDataObjectExpressionLanguage

java.lang.Object
com.luciad.datamodel.expression.ALcdDataObjectExpressionLanguage
com.luciad.datamodel.expression.TLcdDataObjectExpressionLanguage

public class TLcdDataObjectExpressionLanguage extends ALcdDataObjectExpressionLanguage
Default implementation of ALcdDataObjectExpressionLanguage. This language allows the following kinds of expressions:
  • Property names: a property name is evaluated to the value of that property. A chain of property names can be set up using the dot operator. For example, consider a Person type that has 3 properties: name, child (links to another Person object) and children (a list property also of type Person). Given an object of such a type as root, the following expressions are supported:
    • name returns the value of the name property of the root object.
    • child.name returns the value of the name property of the root object's child. If the root object has no child, null is returned.
    • children.name returns a list containing all the names (that are not null) of the root object's children
  • Custom functions: the language supports the registration of custom functions (see getFunctions(). These functions compute a value based on a number of arguments.
    The arguments can be either other expressions or constants. Constants are placed between single quotes. For instance '2' or 'myString'. These constants evaluate to a String.
    • toUpper(child.name) returns the name of the root object's child in upper case (as returned by the 'toUpper' function registered in the function context).
    • favourite(children).name returns the name of the root object's favourite child (as returned by the 'favourite' function), or null in case the function returned null.
    The default implementation does not contain any pre-defined functions. Applications should not register functions with names starting with Lcd as these names are reserved for future use.
  • Index-based selection: in case an expression is evaluated into a List, index-based selection can be applied to select the element at the given position in the list. For instance, children[3].name returns the name of the root object's fourth child (the index of the first element in the list is 0) or null in case the root object does not have 4 children.
More formally, the syntax for this language is as follows:

  <Expression> = 
   [ <Expression> "." ] <PropertyName> |
   <FunctionCall> | 
   <Expression> "[" <Number> "]" |
   "'" <Literal> "'"
 <FunctionCall> = <FunctionName> "(" [ <Expression> ( "," <Expression> )* ] ")"
 
Since:
10.1
  • Constructor Details

    • TLcdDataObjectExpressionLanguage

      public TLcdDataObjectExpressionLanguage()
  • Method Details

    • getFunctions

      Returns the function context of this language. Functions that are added to this map can be used in expressions.
      Returns:
      the function context of this language
    • compile

      public ILcdDataObjectExpression compile(String aExpression)
      Description copied from class: ALcdDataObjectExpressionLanguage
      Compiles the expression to an intermediate representation. This can be used to improve performance when the same expression needs to be evaluated in different contexts.
      Specified by:
      compile in class ALcdDataObjectExpressionLanguage
      Parameters:
      aExpression - the expression to compile
      Returns:
      a compiled expression
    • update

      public void update(String aExpression, ILcdDataObject aRoot, Object aValue)
      Updates the value in a data object identified by the passed expression. Only straight property expressions, like PropertyName1.PropertyName2..., are supported, see createExpression(com.luciad.datamodel.TLcdDataType, com.luciad.datamodel.TLcdDataProperty...). Expressions pointing to elements inside a list, like ListPropertyName[0], functions or complex expressions combining multiple properties can't be handled by this method.
      Parameters:
      aExpression - the expression describing which property to update,
      aRoot - the root data object.
      aValue - the new value.
    • createExpression

      public static String createExpression(TLcdDataType aDataType, TLcdDataProperty... aDataProperties)
      Utility method to create the expression pointing to the value of a certain property. If more than one data property is passed it points to a property of the value, which must be a ILcdDataObject itself, of a property etc...
      Parameters:
      aDataType - the root data type
      aDataProperties - one or more data properties, the first data property should be a property of an extension or supertype of aDataType, and the other data properties should be a property of an extension or super type of the type of the previous data property.
      Returns:
      an expression representing a path from the passed dataType down to a (nested) property.
      Throws:
      IllegalArgumentException - if:
      • aDataType is null
      • aDataProperties is null or empty
      • one of the data properties is not a property of the type of the previous data property.
    • getExpressionProperties

      public static TLcdDataProperty[] getExpressionProperties(TLcdDataType aDataType, String aExpression) throws IllegalArgumentException
      This method will convert a straight property, like PropertyName1.PropertyName2..., expression to an TLcdDataProperty array. It is the reverse of the method createExpression(com.luciad.datamodel.TLcdDataType, com.luciad.datamodel.TLcdDataProperty...).
      Parameters:
      aDataType - the root data type
      aExpression - an expression representing a path from the passed dataType down to a (nested) property.
      Returns:
      an array of data properties corresponding to the expression.
      Throws:
      IllegalArgumentException - when the expression is not valid for the given data type.
      See Also: