Value range of the List data type
In FirstSpirit, elements of the template development can be grouped in:
FirstSpirit provides the data type List for the editing / processing of values which represent an ordered, indexed set of list elements. This data type enables a grouping of elements. Lists are very flexible and can be extended as required. By specifying an index value, which determines the position within the list, it is possible to define the position in the list in which an element is to be inserted or read out. Unlike the data type Set, elements can occur more than once within a list.
The data type List can also be looked up in the Sun API documentation:
java.util.List
Definition
Lists can also be generated via [ ] (square brackets). The following syntax must be fulfilled:
LIST := '[]' | [ EXPRESSION [',' EXPRESSION ]* ] ']' | '[' EXPRESSION' .. ' EXPRESSION ']'
The following code example generates an empty list and assigns to it the empty_list variable:
$CMS_SET(empty_list, [])$
If a filled list is to be generated, i.e. a list which already contains elements, the elements are simply passed as a comma-separated list within the square brackets. The code example generates a new, filled list list:
$CMS_SET(list, [1,2,3])$
By stating the index, the position at which the transferred value should be inserted can be determined. Existing values will be overwritten. Code example:
$CMS_SET(list[0], "4")$
Output:
[4, 2, 3]
Access to elements in the list
Elements in a list are accessed via the list's index.
The index can be defined by a constant value:
list[2]
or via a variable:
list[i]
analogous to this:
list.get(2)
list.get(i)
Examples:
$CMS_VALUE(list.get(2))$
or:
$CMS_SET(i, 2)$
$CMS_VALUE(list, [i])$
Both examples return the third element in the list (Index always begins with 0!).
Analogous to this a new list element can be set via the index in a specific position in the list:
$CMS_SET(list[0], "new")$
With this instruction the new string is set in the first position in the list.
All elements of a list can also be set simultaneously. The position then depends on the order of the elements within the $CMS_SET(list, [...])$ instruction.
$CMS_SET(list, ["a","b","c"])$
Sorting the list elements
The sort method can be used to sort lists in ascending order:
$CMS_SET(list, ["C", "E", "B", "D", "A"])$
$CMS_VALUE(list.sort)$
The output is:
[A, B, C, D, E]
The reverse method reverses the order of the list elements:
$CMS_SET(list, ["C", "E", "B", "D", "A"])$
$CMS_VALUE(list.reverse)$
Output:
[A, D, B, E, C]
Both methods are combined to obtain sorting in descending order:
$CMS_SET(list, ["C", "E", "B", "D", "A"])$
$CMS_VALUE(list.sort.reverse)$
Output:
[E, D, C, B, A]
Methods on list objects
The table below lists all methods which can be invoked on objects of data type List.
Method name |
Return type |
Brief description |
Available since |
add(List) |
List |
|
|
add(Object) |
List |
|
|
add(int, Object) |
void |
|
|
addAll(Collection) |
boolean |
|
|
addAll(int, Collection) |
boolean |
|
|
clear |
void |
|
|
contains(Object) |
boolean |
checks if the provided element is contained |
4.0.0 |
containsAll(Collection) |
boolean |
checks if all elements of the provided element are contained |
4.0.0 |
copy |
Collection |
make a (shallow) copy |
4.0.0 |
copyOf(Collection) |
List |
|
|
distinct(Lambda) |
Collection |
Output of a list of unique elements |
4.1 |
equals(Object) |
boolean |
|
|
filter(String) |
Object |
delivers a filtered collection, the last parameter converted to a lambda expression |
4.0.0 |
filter(Lambda) |
Object |
Filtering of list elements |
4.0.0 |
first |
Object |
|
|
fold(Lambda, Map) |
Object |
Summarizing values |
4.0.0 |
forEach(Consumer) |
void |
|
|
get(Range) |
Object |
|
|
get(int) |
Object |
|
|
getClass |
Class |
Class of the invoking object |
|
hashCode |
int |
|
|
indexOf(Object) |
int |
|
|
isCase(Object) |
boolean |
|
|
isEmpty |
boolean |
Checks whether an expression is empty |
|
isNull |
boolean |
Checks whether an expression is null (zero) |
|
iterator |
Iterator |
|
|
last |
Object |
|
|
lastIndexOf(Object) |
int |
|
|
length |
int |
|
|
listIterator |
ListIterator |
|
|
listIterator(int) |
ListIterator |
|
|
map(String) |
Object |
delivers a mapped collection, the last parameter converted to a lambda expression |
4.0.0 |
map(Lambda) |
Object |
Output of list elements as collection |
4.0.0 |
max |
Object |
delivers the maximum element (only applicable if elements are compareable) |
4.0.0 |
max(Comparator) |
Object |
delivers the maximum element concerning to the given comparator |
4.0.0 |
max(Lambda) |
Object |
Filtering by the highest value |
4.0.0 |
min |
Object |
delivers the minimum element (only applicable if elements are compareable) |
4.0.0 |
min(Comparator) |
Object |
delivers the minimum element concerning to the given comparator |
4.0.0 |
min(Lambda) |
Object |
Filtering by the lowest value |
4.0.0 |
of |
List |
|
|
of(Object[]) |
List |
|
|
of(Object) |
List |
|
|
of(Object, Object) |
List |
|
|
of(Object, Object, Object) |
List |
|
|
of(Object, Object, Object, Object) |
List |
|
|
of(Object, Object, Object, Object, Object) |
List |
|
|
of(Object, Object, Object, Object, Object, Object) |
List |
|
|
of(Object, Object, Object, Object, Object, Object, Object) |
List |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object) |
List |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object) |
List |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
List |
|
|
plus(Collection) |
Collection |
|
|
print |
void |
|
|
print(Object) |
void |
|
|
remove(int) |
Object |
|
|
remove(Object) |
boolean |
|
|
removeAll(Collection) |
boolean |
|
|
removeIf(Predicate) |
boolean |
|
|
replaceAll(UnaryOperator) |
void |
|
|
retainAll(Collection) |
boolean |
|
|
reverse |
List |
|
|
set(int, Object) |
List |
|
|
set(String, Object) |
Object |
|
|
size |
int |
the number of contained elements |
4.0.0 |
sort |
List |
|
|
sort(String) |
List |
|
|
sort(Comparator) |
List |
|
|
sort(Lambda) |
List |
Sorting of list elements |
|
spliterator |
Spliterator |
|
|
subList(int) |
List |
|
|
subList(int, int) |
List |
|
|
sublist(int) |
List |
|
|
sublist(int, int) |
List |
|
|
toArray |
Object[] |
|
|
toArray(Object[]) |
Object[] |
|
|
toArray(IntFunction) |
Object[] |
|
|
toJSON |
String |
Convert to a JSON-compatible string representation including necessary quotes and escaping for immediate use. Handles Maps, Collections, Arrays, Numbers, Strings, Boolean, Date, and JsonElement. A date instance will be converted to an ISO-8601 formatted date string. Any object other than above will be converted using its 'toString()' value. |
5.2.11 |
toList |
List |
Converts a collection to a list. |
5.2.416 |
toString |
String |
|
|
toString(String) |
String |
Output of elements separated by delimiters as a string |
4.0.0 |
toString(String, String) |
String |
Short form for collection.map(attribute).toString(delimiter) |
4.0.0 |
type |
String |
|
|
add(List)
Method name |
Return type |
Available since |
add(List) |
List |
|
Overview
add(Object)
Method name |
Return type |
Available since |
add(Object) |
List |
|
Overview
add(int, Object)
Method name |
Return type |
Available since |
add(int, Object) |
void |
|
Overview
addAll(Collection)
Method name |
Return type |
Available since |
addAll(Collection) |
boolean |
|
Overview
addAll(int, Collection)
Method name |
Return type |
Available since |
addAll(int, Collection) |
boolean |
|
Overview
clear
Method name |
Return type |
Available since |
clear |
void |
|
Overview
contains(Object)
checks if the provided element is contained
Method name |
Return type |
Available since |
contains(Object) |
boolean |
4.0.0 |
Overview
containsAll(Collection)
checks if all elements of the provided element are contained
Method name |
Return type |
Available since |
containsAll(Collection) |
boolean |
4.0.0 |
Overview
copy
make a (shallow) copy
Method name |
Return type |
Available since |
copy |
Collection |
4.0.0 |
Overview
copyOf(Collection)
Method name |
Return type |
Available since |
copyOf(Collection) |
List |
|
Overview
distinct(Lambda)
This method filters a collection and returns only the first occurrence relating to a lambda expression.
It can be used to eliminate or ignore duplicates of a list according to a given condition. For this reason, it can be used for glossaries or summaries, which can then serve linked, for example, as navigational element.
See page Mapping expressions (lambda).
Method name |
Return type |
Available since |
distinct(Lambda) |
Collection |
4.1 |
Overview
equals(Object)
Method name |
Return type |
Available since |
equals(Object) |
boolean |
|
Overview
filter(String)
delivers a filtered collection, the last parameter converted to a lambda expression
Method name |
Return type |
Available since |
filter(String) |
Object |
4.0.0 |
Overview
filter(Lambda)
If lists have several attributes per element (comparable with a dataset with several columns), the elements can be filtered by the individual attributes using the method .filter(Lambda).
See page Mapping expressions (lambda).
Method name |
Return type |
Available since |
filter(Lambda) |
Object |
4.0.0 |
Overview
first
Method name |
Return type |
Available since |
first |
Object |
|
Overview
fold(Lambda, Map)
This method folds the collection with the given lambda expression and start value.
See page Mapping expressions (lambda).
Method name |
Return type |
Available since |
fold(Lambda, Map) |
Object |
4.0.0 |
Overview
forEach(Consumer)
Method name |
Return type |
Available since |
forEach(Consumer) |
void |
|
Overview
get(Range)
Method name |
Return type |
Available since |
get(Range) |
Object |
|
Overview
get(int)
Method name |
Return type |
Available since |
get(int) |
Object |
|
Overview
getClass
The .getClass() (in Bean syntax: .class) method returns the class of the invoking object (cf. java.lang.Class).
Invocation:
$CMS_VALUE(myString.class)$
$CMS_VALUE(myString.getClass())$
Output:
java.lang.String
Method name |
Return type |
Available since |
getClass |
Class |
|
Overview
hashCode
Method name |
Return type |
Available since |
hashCode |
int |
|
Overview
indexOf(Object)
Method name |
Return type |
Available since |
indexOf(Object) |
int |
|
Overview
isCase(Object)
Method name |
Return type |
Available since |
isCase(Object) |
boolean |
|
Overview
isEmpty
The .isEmpty() (in Bean syntax: .isEmpty) method checks whether an expression or object is empty, e.g. storeElement.isEmpty(). The result of the semantic check depends on the expression or object, e.g. a character string is empty if it does not contain any characters. In the case of objects with complex values or objects, the object decides when it is empty. The data type DomElement for example always contains an empty document, thus it is never null. For this reason, checking an empty DOM editor input component by using the method .isNull()returns the value false, whereas checking the component with .isEmpty() would return the value true.
The method .isEmpty() returns a Boolean value as the check result. true is the check result if the expression or object is empty and false if not.
Method name |
Return type |
Available since |
isEmpty |
boolean |
|
Overview
isNull
The .isNull() (in Bean syntax: .isNull) method checks whether an expression or object is null , e.g. storeElement.isNull(). In the case of objects with complex values or objects, the object decides when it is null. The data type DomElement for example always contains an empty document, thus it is never null. For this reason, checking an empty DOM editor input component by using the method .isNull() returns the value false, whereas checking the component with .isEmpty() would return the value true.
The method .isNull() returns a Boolean value as the check result. true is the check result if the expression or object is null and false if not.
Method name |
Return type |
Available since |
isNull |
boolean |
|
Overview
iterator
Method name |
Return type |
Available since |
iterator |
Iterator |
|
Overview
last
Method name |
Return type |
Available since |
last |
Object |
|
Overview
lastIndexOf(Object)
Method name |
Return type |
Available since |
lastIndexOf(Object) |
int |
|
Overview
length
Method name |
Return type |
Available since |
length |
int |
|
Overview
listIterator
Method name |
Return type |
Available since |
listIterator |
ListIterator |
|
Overview
listIterator(int)
Method name |
Return type |
Available since |
listIterator(int) |
ListIterator |
|
Overview
map(String)
delivers a mapped collection, the last parameter converted to a lambda expression
Method name |
Return type |
Available since |
map(String) |
Object |
4.0.0 |
Overview
map(Lambda)
See page Mapping expressions (lambda).
Method name |
Return type |
Available since |
map(Lambda) |
Object |
4.0.0 |
Overview
max
delivers the maximum element (only applicable if elements are compareable)
Method name |
Return type |
Available since |
max |
Object |
4.0.0 |
Overview
max(Comparator)
delivers the maximum element concerning to the given comparator
Method name |
Return type |
Available since |
max(Comparator) |
Object |
4.0.0 |
Overview
max(Lambda)
This method delivers the maximum element concerning to the given comparator.
See page Mapping expressions (lambda).
Method name |
Return type |
Available since |
max(Lambda) |
Object |
4.0.0 |
Overview
min
delivers the minimum element (only applicable if elements are compareable)
Method name |
Return type |
Available since |
min |
Object |
4.0.0 |
Overview
min(Comparator)
delivers the minimum element concerning to the given comparator
Method name |
Return type |
Available since |
min(Comparator) |
Object |
4.0.0 |
Overview
min(Lambda)
This method delivers the minimum element concerning to the given comparator.
See page Mapping expressions (lambda).
Method name |
Return type |
Available since |
min(Lambda) |
Object |
4.0.0 |
Overview
of
Method name |
Return type |
Available since |
of |
List |
|
Overview
of(Object[])
Method name |
Return type |
Available since |
of(Object[]) |
List |
|
Overview
of(Object)
Method name |
Return type |
Available since |
of(Object) |
List |
|
Overview
of(Object, Object)
Method name |
Return type |
Available since |
of(Object, Object) |
List |
|
Overview
of(Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object) |
List |
|
Overview
of(Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object) |
List |
|
Overview
of(Object, Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object, Object) |
List |
|
Overview
of(Object, Object, Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object, Object, Object) |
List |
|
Overview
of(Object, Object, Object, Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object, Object, Object, Object) |
List |
|
Overview
of(Object, Object, Object, Object, Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object, Object, Object, Object, Object) |
List |
|
Overview
of(Object, Object, Object, Object, Object, Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object, Object, Object, Object, Object, Object) |
List |
|
Overview
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
List |
|
Overview
plus(Collection)
Method name |
Return type |
Available since |
plus(Collection) |
Collection |
|
Overview
print
Method name |
Return type |
Available since |
print |
void |
|
Overview
print(Object)
Method name |
Return type |
Available since |
print(Object) |
void |
|
Overview
remove(int)
Method name |
Return type |
Available since |
remove(int) |
Object |
|
Overview
remove(Object)
Method name |
Return type |
Available since |
remove(Object) |
boolean |
|
Overview
removeAll(Collection)
Method name |
Return type |
Available since |
removeAll(Collection) |
boolean |
|
Overview
removeIf(Predicate)
Method name |
Return type |
Available since |
removeIf(Predicate) |
boolean |
|
Overview
replaceAll(UnaryOperator)
Method name |
Return type |
Available since |
replaceAll(UnaryOperator) |
void |
|
Overview
retainAll(Collection)
Method name |
Return type |
Available since |
retainAll(Collection) |
boolean |
|
Overview
reverse
Method name |
Return type |
Available since |
reverse |
List |
|
Overview
set(int, Object)
Method name |
Return type |
Available since |
set(int, Object) |
List |
|
Overview
set(String, Object)
Method name |
Return type |
Available since |
set(String, Object) |
Object |
|
Overview
size
the number of contained elements
Method name |
Return type |
Available since |
size |
int |
4.0.0 |
Overview
sort
Method name |
Return type |
Available since |
sort |
List |
|
Overview
sort(String)
Method name |
Return type |
Available since |
sort(String) |
List |
|
Overview
sort(Comparator)
Method name |
Return type |
Available since |
sort(Comparator) |
List |
|
Overview
sort(Lambda)
If lists have several attributes per element (comparable with a dataset with several columns), the elements can be sorted by the individual attributes using the method .sort(Lambda).
See page Mapping expressions (lambda).
Method name |
Return type |
Available since |
sort(Lambda) |
List |
|
Overview
spliterator
Method name |
Return type |
Available since |
spliterator |
Spliterator |
|
Overview
subList(int)
Method name |
Return type |
Available since |
subList(int) |
List |
|
Overview
subList(int, int)
Method name |
Return type |
Available since |
subList(int, int) |
List |
|
Overview
sublist(int)
Method name |
Return type |
Available since |
sublist(int) |
List |
|
Overview
sublist(int, int)
Method name |
Return type |
Available since |
sublist(int, int) |
List |
|
Overview
toArray
Method name |
Return type |
Available since |
toArray |
Object[] |
|
Overview
toArray(Object[])
Method name |
Return type |
Available since |
toArray(Object[]) |
Object[] |
|
Overview
toArray(IntFunction)
Method name |
Return type |
Available since |
toArray(IntFunction) |
Object[] |
|
Overview
toJSON
Convert to a JSON-compatible string representation including necessary quotes and escaping for immediate use. Handles Maps, Collections, Arrays, Numbers, Strings, Boolean, Date, and JsonElement. A date instance will be converted to an ISO-8601 formatted date string. Any object other than above will be converted using its 'toString()' value.
Method name |
Return type |
Available since |
toJSON |
String |
5.2.11 |
Overview
toList
Converts a collection to a list.
Method name |
Return type |
Available since |
toList |
List |
5.2.416 |
Overview
toString
Method name |
Return type |
Available since |
toString |
String |
|
Overview
toString(String)
The individual elements, e.g. of a list, can be output as string, separated by a delimiter which can be chosen freely.
Example:
$CMS_SET(myList, ["House","Key","Window"])$
$CMS_VALUE(myList.toString("; "))$
The elements of the list myList are output, separated each by semicolon and a space character:
House; Key; Window
Method name |
Return type |
Available since |
toString(String) |
String |
4.0.0 |
Overview
toString(String, String)
Short form for collection.map(attribute).toString(delimiter)
Method name |
Return type |
Available since |
toString(String, String) |
String |
4.0.0 |
Overview
type
Method name |
Return type |
Available since |
type |
String |
|
Overview