
OGNL Language Guide
Drew Davidson

OGNL Language Guide
Drew Davidson
Copyright © 2004 OGNL Technology, Inc.


Table of Contents
1. Introduction ............................................................................................................1
2. History ..................................................................................................................2
3. Syntax ...................................................................................................................3
4. Expressions ............................................................................................................4
Constants ...........................................................................................................4
Referring to Properties .........................................................................................4
Indexing ............................................................................................................4
Array and List Indexing ................................................................................5
JavaBeans Indexed Properties ........................................................................5
OGNL Object Indexed Properties ...................................................................5
Calling Methods .................................................................................................5
Variable References .............................................................................................6
Parenthetical Expressions .....................................................................................6
Chained Subexpressions .......................................................................................6
Collection Construction ........................................................................................7
Lists .........................................................................................................7
Native Arrays .............................................................................................7
Maps ........................................................................................................7
Projecting Across Collections ................................................................................8
Selecting From Collections ...................................................................................8
Selecting First Match ...................................................................................8
Selecting Last Match ...................................................................................8
Calling Constructors ............................................................................................8
Calling Static Methods ......................................................................................... 9
Getting Static Fields ............................................................................................9
Expression Evaluation .......................................................................................... 9
Pseudo-Lambda Expressions ................................................................................. 9
Pseudo-Properties for Collections ......................................................................... 10
Operators that differ from Java's operators ............................................................. 11
Setting values versus getting values ...................................................................... 11
5. Coercing Objects to Types ....................................................................................... 13
Interpreting Objects as Booleans .......................................................................... 13
Interpreting Objects as Numbers .......................................................................... 13
Interpreting Objects as Integers ............................................................................ 13
Interpreting Objects as Collections ....................................................................... 14
A. OGNL Language Reference .................................................................................... 15
Operators ......................................................................................................... 15
iv

List of Tables
3.1. OGNL Expression Parts .........................................................................................3
4.1. Special Collections Pseudo-Properties ..................................................................... 10
A.1. OGNL Operators ................................................................................................ 15
v