Products Downloads


French version


 

This function returns a Hash-type object which has add, change and delete methods: this object is an encapsulation of the Java LinkedHashMap object (click here for more details). Some methods from the LinkedHashMap class can be used in a FreeMarker execution context: clear/containsValue/containsKey isEmpty/keySet/size/remove/values/get/getOrDefault/put/putIfAbsent/replace.

 

Differences between "createSimpleHash" and "createSimpleMap":

  • The Hash-type object returned by "createSimpleMap" cannot be used in "addToSimpleHash" and "removeFromSimpleHash" functions (which relate to a Hash object created by the "createSimpleHash" function),
  • The Hash-type object returned by "createSimpleMap" does not support the built-in ?keys, ?values and ?size functions, unlike a Hash object returned by "createSimpleHash". The equivalent methods keySet, values and size need to be used for a Hash object returned by "createSimpleMap",
  • The keys of a Hash object returned by "createSimpleMap" may be of any type, unlike a Hash object returned by "createSimpleHash" which has its alphanumeric-type keys,
  • The <#list aHashObject as aKey, aValue>...</#list> directive (list of keys/values of a Hash object) can only be executed for a Hash object created by the "createSimpleHash" function. The <#list aHashObject.keySet() as aKey><#-- Get the value via the aHashObject.get(aKey) expression -->...</#list> equivalent needs to be used

 

Parameters

No parameter.

 

For example

<#assign aHashObj = hardisCore.createSimpleMap() />
Size of Hash object:${aHashObj.size()}
<#-- The put Java method does not return a value so we have to return a empty default value for assign directive -->
<#assign noUse = aHashObj.put("key1", "value1")!"" />
<#assign noUse = aHashObj.put(2, "value2")!"" />
<#list aHashObj.keySet() as aKey>
The key is ${aKey} and the associated value is ${aHashObj.get(aKey)}
</#list> 

↑ Top of page