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 Link can also be looked up in the Sun 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 an empty map and assigns the variable "map" to it:
$CMS_SET(map, { })$
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, file map "map" with the key "name" and the value "mustermann":
$CMS_SET(map, {"name":"Mustermann", "firstname":"Heinz"})$
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 |
clear
Method name |
Return type |
Available since |
clear |
void |
|
Overview
compareTo(Comparable)
Method name |
Return type |
Available since |
compareTo(Comparable) |
int |
|
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
entrySet
Method name |
Return type |
Available since |
entrySet |
Set |
|
Overview
equals(Object)
Method name |
Return type |
Available since |
equals(Object) |
boolean |
|
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
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
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
remove(Object)
Method name |
Return type |
Available since |
remove(Object) |
Object |
|
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 pair 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 JSON string representtion (only handles Maps, Collections, Arrays, Numbers, and Strings)
Method name |
Return type |
Available since |
toJson |
String |
4.2.14 |
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