This group of functions allows using element maps maintained by the generator.
What are Element Maps?
If you are going to process data sources with a large number of elements, the element maps may help you to make your templates work a lot faster (or even work them at all).
Suppose, you frequently need to obtain from a large number of elements some collections of them using rather complicated and varying query (which may depend on some external parameters). You may notice that in many instances such a query can be presented actually as a composition of two subqueries:
(Of course, such an approach may cost some memory, but given that during processing of a template some of its components may be implicitly executed a lot number of times, this will pay off and may considerably boost the generator performance.)
The FlexDoc generator maintains a table of special hashmaps that associate keys with certain collections of elements. Those hashmaps called elemeny maps can be created and accessed within FlexQuery expressions in templates.
Each element map is identified by a certain object called elementMapId
.
That identifier is specified when the element map is created
and, then, should be used as a parameter with any function accessing it.
The generator maintains the whole element map table as yet another hashmap,
so each elementMapId
object is used as a map key in it and,
therefore, should comply with what is needed to be a good hash key.
See description for createElementMap()
function
for more details about that.
Each element map contains certain keys and the elements associated with those key.
The elements are the DSM (Data Source Model) elements represented by
GOMElement
objects. The elements are distinguished by their unique identifiers
(see GOMElement.id
), so different GOMElement
instances are considered
to represent the same element as long as their id
are equal.
The map keys may be any objects good to be hash keys.
Each element map represents a certain relation between keys and elements. The same element may be associated with different keys in the map as well as any key may have multiple elements associated with it.
Working with Element Maps
The following is the summary of the functions working with element maps:
createElementMap()
createElementMaps()
checkElementMap()
clearElementMap()
removeElementMap()
putElementByKey()
putElementByKeys()
putElementsByKey()
putElementsByKeys()
prepareElementMap()
checkElementMap()
,
createElementMap()
and putElementsByKeys()
functions at once.
It tests if the element map with the specified identifier exists. If yes, the function does nothing and just returns the number of key/element associations contained in the map.
If the element map does not exist, the function creates it and fill with the key/element
associations the same way as putElementsByKeys()
function.
removeElementByKey()
removeElementsByKey()
findElementByKey()
findElementsByKey()
findElementsByKeys()
checkElementsByKey()
checkElementsByKeys()
countElementsByKey()
countElementsByKeys()
countMappedElements()
getMappedElements()
getElementMapKeys()