public class TLcdDataObjectExpressionLanguage extends ALcdDataObjectExpressionLanguage
ALcdDataObjectExpressionLanguage
. This language allows
the following kinds of expressions:
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 childrengetFunctions()
. These functions compute a value based
on a number of arguments. 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
.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.
<Expression> =
[ <Expression> "." ] <PropertyName> |
<FunctionCall> |
<Expression> "[" <Number> "]" |
"'" <Literal> "'"
<FunctionCall> = <FunctionName> "(" [ <Expression> ( "," <Expression> )* ] ")"
Modifier and Type | Class and Description |
---|---|
static interface |
TLcdDataObjectExpressionLanguage.Function
Custom function that computes a value given a list of arguments.
|
Constructor and Description |
---|
TLcdDataObjectExpressionLanguage() |
Modifier and Type | Method and Description |
---|---|
ILcdDataObjectExpression |
compile(String aExpression)
Compiles the expression to an intermediate representation.
|
static String |
createExpression(TLcdDataType aDataType,
TLcdDataProperty... aDataProperties)
Utility method to create the expression pointing to the value of a certain property.
|
static TLcdDataProperty[] |
getExpressionProperties(TLcdDataType aDataType,
String aExpression)
This method will convert a straight property, like
PropertyName1.PropertyName2... ,
expression to an TLcdDataProperty array. |
Map<String,TLcdDataObjectExpressionLanguage.Function> |
getFunctions()
Returns the function context of this language.
|
void |
update(String aExpression,
ILcdDataObject aRoot,
Object aValue)
Updates the value in a data object identified by the passed expression.
|
createContext, evaluate, evaluate
public Map<String,TLcdDataObjectExpressionLanguage.Function> getFunctions()
public ILcdDataObjectExpression compile(String aExpression)
ALcdDataObjectExpressionLanguage
compile
in class ALcdDataObjectExpressionLanguage
aExpression
- the expression to compilepublic void update(String aExpression, ILcdDataObject aRoot, Object aValue)
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.aExpression
- the expression describing which property to update,aRoot
- the root data object.aValue
- the new value.public static String createExpression(TLcdDataType aDataType, TLcdDataProperty... aDataProperties)
ILcdDataObject
itself, of a property etc...aDataType
- the root data typeaDataProperties
- 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.IllegalArgumentException
- if: aDataType
is nullaDataProperties
is null or emptypublic static TLcdDataProperty[] getExpressionProperties(TLcdDataType aDataType, String aExpression) throws IllegalArgumentException
PropertyName1.PropertyName2...
,
expression to an TLcdDataProperty
array. It is the reverse of the method createExpression(com.luciad.datamodel.TLcdDataType, com.luciad.datamodel.TLcdDataProperty...)
.aDataType
- the root data typeaExpression
- an expression representing a path from the passed dataType down to a (nested) property.IllegalArgumentException
- when the expression is not valid for the given data type.createExpression(com.luciad.datamodel.TLcdDataType, com.luciad.datamodel.TLcdDataProperty...)