Skip to main content
This revision made December 08, 2011 19:00, by Kin-man Chung
« earlier revision revert to this « later revision

Collection Construction

The syntax for construction of collection objects follows the syntax that has been proposed for JDK 8 Collection literals. Note that EL 3.0 allows any expressions in the construction, and is not limited to literals.

List

Syntax"

    ListData := '[' DataList ']'
    DataList :=  (expression (',' expression)*)?

Example:

   [1, "two", 3.0]

Implemented with:

   java.util.ArrayList

Set

Syntax:

   SetData := '{' DataList '}'

Example:

   {1, 2, 3}

Implemented with:

   java.util.HashSet (LinkedHasSet?)

Map

Syntax:

    Map := '{' MapEntries '}'
    MapEntries := (MapEntry (',' MapEntry)* )?
    MapEntry := expression ':' expression

Examples:

    {"one":1, "two":2, "three":3}
    {12:true, "foo":1+2}

Implemented with:

   java.util.HasMap

There is no syntax for construction of Java arrays. In most cases, List can be used instead. The method List.toArray() can be used to convert a List to an array, when needed (e.g. if the target type is an array).

Difference compared to previous revision
<span>(No Modifications)<span>
 
 
Close
loading
Please Confirm
Close