Map data type
Value range of the Map data type
Elements of the template development can be grouped in:
FirstSpirit provides the Map data type for the processing/editing of values which represent a set of key value pairs. This data type enables grouping of elements represented by a set of unique key values (“keys”) to which specific contents (“values”) are assigned. Any number of key value pairs can be created within a map object. The values are always accessed via the key.
The data type Map can also be looked up in the Oracle API documentation:
java.util.Map
Definition
Maps can be generated via { } (curly brackets). The following syntax must be fulfilled:
MAP := '{' EXPRESSION ':' EXPRESSION [',' EXPRESSION ':' EXPRESSION ]* ] '}'
The following code example generates a map with one entry and assigns the variable map to it:
$CMS_SET(map, { "key" : "value" })$
You can create an empty map as follows:
$CMS_SET(map,{:})$
The statement { } does not create a map, but a Set.
If a filled map is to be generated, i.e. a map which already contains key value pairs, these are passed as a comma-separated list within the curly brackets. The key and value are separated by a :. The following code example generates a new, filled map map with the key name and the value Mustermann and a key firstname and the related value Heinz:
$CMS_SET(map, {"name":"Mustermann", "firstname":"Heinz"})$
Use the following syntax to add a key value pair to an existing map (in this case with the identifier map):
$CMS_SET( map["key"], "value")$
or
$CMS_SET(void,map.put("key","value"))$
Access to map values
The map values are accessed solely via assigned key values whereby each of the following expressions is valid and returns the given output:
$CMS_VALUE(map.get("name"))$
$CMS_VALUE(map.name)$
$CMS_VALUE(map["name"])$
Output:
Mustermann
The following code example iterates across all elements of the map and outputs all available key value pairs:
$CMS_FOR(mapWrapper,map)$
$CMS_VALUE(mapWrapper)$
$CMS_END_FOR$
Output:
mapWrapper:name=Mustermann
mapWrapper:firstname=Heinz
Methods on map objects
The table below lists all methods which can be invoked on objects of data type "Map":
The object is generated by the following form objects: |
---|
FS_BUTTON |
Method name |
Return type |
Brief description |
Available since |
clear |
void |
|
|
compute(Object, BiFunction) |
Object |
|
|
computeIfAbsent(Object, Function) |
Object |
|
|
computeIfPresent(Object, BiFunction) |
Object |
|
|
containsKey(Object) |
boolean |
|
|
containsValue(Object) |
boolean |
|
|
copyOf(Map) |
Map |
|
|
entry(Object, Object) |
Map$Entry |
|
|
entrySet |
Set |
|
|
equals(Object) |
boolean |
|
|
forEach(BiConsumer) |
void |
|
|
get(Set) |
Set |
|
|
get(Collection) |
List |
|
|
get(String) |
Object |
Value of a key |
|
get(Object) |
Object |
|
|
getClass |
Class |
Class of the invoking object |
|
getOrDefault(Object, Object) |
Object |
|
|
hashCode |
int |
|
|
isCase(Object) |
boolean |
|
4.2.14 |
isEmpty |
boolean |
Checks whether an expression is empty |
|
isNull |
boolean |
Checks whether an expression is null (zero) |
|
keySet |
Set |
|
|
merge(Object, Object, BiFunction) |
Object |
|
|
of |
Map |
|
|
of(Object, Object) |
Map |
|
|
of(Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
|
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
|
ofEntries(Map$Entry[]) |
Map |
|
|
print |
void |
|
|
put(Object, Object) |
Object |
|
|
putAll(Map) |
void |
|
|
putIfAbsent(Object, Object) |
Object |
|
|
remove(Object) |
Object |
|
|
remove(Object, Object) |
boolean |
|
|
replace(Object, Object) |
Object |
|
|
replace(Object, Object, Object) |
boolean |
|
|
replaceAll(BiFunction) |
void |
|
|
set(String, Object) |
Object |
|
|
set(Object, Object) |
Map |
|
|
size |
int |
Number of the key/value pairs |
|
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 |
toString |
String |
|
|
type |
String |
|
|
values |
Collection |
|
|
clear
Method name |
Return type |
Available since |
clear |
void |
|
Overview
compute(Object, BiFunction)
Method name |
Return type |
Available since |
compute(Object, BiFunction) |
Object |
|
Overview
computeIfAbsent(Object, Function)
Method name |
Return type |
Available since |
computeIfAbsent(Object, Function) |
Object |
|
Overview
computeIfPresent(Object, BiFunction)
Method name |
Return type |
Available since |
computeIfPresent(Object, BiFunction) |
Object |
|
Overview
containsKey(Object)
Method name |
Return type |
Available since |
containsKey(Object) |
boolean |
|
Overview
containsValue(Object)
Method name |
Return type |
Available since |
containsValue(Object) |
boolean |
|
Overview
copyOf(Map)
Method name |
Return type |
Available since |
copyOf(Map) |
Map |
|
Overview
entry(Object, Object)
Method name |
Return type |
Available since |
entry(Object, Object) |
Map$Entry |
|
Overview
entrySet
Method name |
Return type |
Available since |
entrySet |
Set |
|
Overview
equals(Object)
Method name |
Return type |
Available since |
equals(Object) |
boolean |
|
Overview
forEach(BiConsumer)
Method name |
Return type |
Available since |
forEach(BiConsumer) |
void |
|
Overview
get(Set)
Method name |
Return type |
Available since |
get(Set) |
Set |
|
Overview
get(Collection)
Method name |
Return type |
Available since |
get(Collection) |
List |
|
Overview
get(String)
A map contains key/value pairs. The .get(String) method can be used to determine the value of the transferred key.
If a map contains the following key/value pairs:
1st pair: key="Max", value="Mustermann"
2nd pair: key="Franz", value="Meier"
3rd pair: key="Peter", value="Müller"
results in the invocation
MAP.get("Franz")
for return of a character string (cf. java.lang.String ) with the content
Meier
Method name |
Return type |
Available since |
get(String) |
Object |
|
Overview
get(Object)
Method name |
Return type |
Available since |
get(Object) |
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
getOrDefault(Object, Object)
Method name |
Return type |
Available since |
getOrDefault(Object, Object) |
Object |
|
Overview
hashCode
Method name |
Return type |
Available since |
hashCode |
int |
|
Overview
isCase(Object)
Method name |
Return type |
Available since |
isCase(Object) |
boolean |
4.2.14 |
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 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
keySet
Method name |
Return type |
Available since |
keySet |
Set |
|
Overview
merge(Object, Object, BiFunction)
Method name |
Return type |
Available since |
merge(Object, Object, BiFunction) |
Object |
|
Overview
of
Method name |
Return type |
Available since |
of |
Map |
|
Overview
of(Object, Object)
Method name |
Return type |
Available since |
of(Object, Object) |
Map |
|
Overview
of(Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object) |
Map |
|
Overview
of(Object, Object, Object, Object, Object, Object)
Method name |
Return type |
Available since |
of(Object, Object, Object, Object, Object, Object) |
Map |
|
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) |
Map |
|
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) |
Map |
|
Overview
of(Object, Object, 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, Object, Object) |
Map |
|
Overview
of(Object, Object, Object, Object, 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, Object, Object, Object, Object) |
Map |
|
Overview
of(Object, Object, Object, Object, Object, Object, 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, Object, Object, Object, Object, Object, Object) |
Map |
|
Overview
of(Object, Object, Object, Object, Object, Object, Object, Object, 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, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
Overview
of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, 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, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) |
Map |
|
Overview
ofEntries(Map$Entry[])
Method name |
Return type |
Available since |
ofEntries(Map$Entry[]) |
Map |
|
Overview
print
Method name |
Return type |
Available since |
print |
void |
|
Overview
put(Object, Object)
Method name |
Return type |
Available since |
put(Object, Object) |
Object |
|
Overview
putAll(Map)
Method name |
Return type |
Available since |
putAll(Map) |
void |
|
Overview
putIfAbsent(Object, Object)
Method name |
Return type |
Available since |
putIfAbsent(Object, Object) |
Object |
|
Overview
remove(Object)
Method name |
Return type |
Available since |
remove(Object) |
Object |
|
Overview
remove(Object, Object)
Method name |
Return type |
Available since |
remove(Object, Object) |
boolean |
|
Overview
replace(Object, Object)
Method name |
Return type |
Available since |
replace(Object, Object) |
Object |
|
Overview
replace(Object, Object, Object)
Method name |
Return type |
Available since |
replace(Object, Object, Object) |
boolean |
|
Overview
replaceAll(BiFunction)
Method name |
Return type |
Available since |
replaceAll(BiFunction) |
void |
|
Overview
set(String, Object)
Method name |
Return type |
Available since |
set(String, Object) |
Object |
|
Overview
set(Object, Object)
Method name |
Return type |
Available since |
set(Object, Object) |
Map |
|
Overview
size
The .size() (in Bean syntax: .size) method returns the number of the key/value pairs in a map.
The returned object is an integer (see java.lang.Integer).
Method name |
Return type |
Available since |
size |
int |
|
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
toString
Method name |
Return type |
Available since |
toString |
String |
|
Overview
type
Method name |
Return type |
Available since |
type |
String |
|
Overview
values
Method name |
Return type |
Available since |
values |
Collection |
|
Overview
Print version | Page start