Object-Graph Navigation Language

from Wikipedia, the free encyclopedia

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 bytethe first value from the resulting array
  • and encapsulates this in an Byteobject, for which the property is determined intValue(by calling the method getIntValue()),
  • the resulting intvalue is Integerencapsulated in an object,
  • which is toString()converted to a string by calling the method .

Projection

listeners.{delegate}

returns a list of all of Delegatesthe Collection listeners.

Selection

listeners.{? #this instanceof KeyListener}

returns one of Collectionall listenerwho KeyListenerare.

Web links