Object-Graph Navigation Language
Object-Graph Navigation Language ( OGNL ) is an expression language for reading and writing properties of Java objects. The same expressions are used to set and read the value of a property. OGNL can be used, for example, to bind a display layer (GUI) to an object in a data model. OGNL also enables projections , selections and pseudo lambda expressions .
In a projection, the same method is called for all elements of a collection or the same property is accessed and the result of this operation (s) is in turn stored in a collection.
In the case of a selection, certain elements from a set of elements in a collection that meet the specified condition are saved as the result in a new collection.
OGNL has a simplified lambda expression syntax that enables simple functions to be written.
Examples
OGNL expression
code.lowerCase.bytes[0].intValue.string
- gets the property
code
, - calls the method for the resulting string
toLowerCase()
, - calls the method for the resulting string
getBytes()
, - extracts
byte
the first value from the resulting array - and encapsulates this in an
Byte
object, for which the property is determinedintValue
(by calling the methodgetIntValue()
), - the resulting
int
value isInteger
encapsulated in an object, - which is
toString()
converted to a string by calling the method .
Projection
listeners.{delegate}
returns a list of all of Delegates
the Collection
listeners
.
Selection
listeners.{? #this instanceof KeyListener}
returns one of Collection
all listener
who KeyListener
are.