Skip to main content
This revision made December 05, 2011 20:33, by Kin-man Chung

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
=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== * =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: [Syntax: [1, "two", 3.0] * 1, "two", 3.0] Implemented with: Implemented with java.util.ArrayList ==Set== * java.util.ArrayList ==Set== Syntax: SetData := '{' DataList '}' Example: {Syntax: {1, 2, 3} * 1, 2, 3} Implemented with: Implemented with java.util.HashSet (LinkedHasSet?) ==Map== * java.util.HashSet (LinkedHasSet?) ==Map== Syntax: Map := '{' MapEntries '}' MapEntries := (MapEntry (',' MapEntry)* )? MapEntry := expression ':' expression Examples: {Syntax: {"one": 1, "two": 2, "three": 3} *"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).
 
 
Close
loading
Please Confirm
Close