Collection manipulation API
Proposal to add set of global operations for ease working with map & list attribute types. Operations mimic java collections. All indexes are 0 based!
Maps
put entry to map
:map-put(name=name-of-attribute, key=some-key, value="newvalue") Remove entry from map:
:map-remove(name=name-of-attribute, key=some-key) Get entry from map:
:map-get(name=name-of-attribute, key=some-key) Empty map, note that is not the same as :undefine(name=name-of-attribute)
:map-clear(name=name-of-attribute) Lists
Add element to list, with optional index where to put it
:list-add(name=list-attribute, value="some value", [index=5]) remove element from list, where you can provide value to remove or from which index to remove it.
:list-remove(name=list-attribute, [value="element-to-remove"], [index=3]) Get entry from list:
:list-get(name=name-of-attribute, index=5) Empty list:
:list-clear(name=attribute-name) Expand standard read/write operations
:write-attribute enhancements for complex attributes
Map write enhancements
:write-attribute(name=map-attribute.myKey value="newValue") List write enhancements
:write-attribute(name=list-attribute[1] value="new-element-value")
:write-attribute(name=list-attribute.element-value value="new-element-value") Map read enhancements
# return value of map-attribute with key "myKey"
:read-attribute(name=map-attribute.myKey) List read enhancements
# return element under index 5 of list-attribute
:read-attribute(name=list-attribute[5]) Generic complex attributes enhancements
# return property.subproperty from complex attribute
:read-attribute(name=complex-attribute.property.subproperty)
# return subproperty of 5th property from complex attribute
:read-attribute(name=complex-attribute[5].subproperty)
# set subproperty of 5th property of complex attribute
:write-attribute(name=complex-attribute[5].subproperty, value="new-value")
# set property.subproperty.subsubproperty of attribute "complext-attribute to "new-value"
:write-attribute(name=complex-attribute.property.subproperty.subsubproperty, value="new-value")
# return value of complex attribute with key "myKey"
:read-attribute(name=complex-attribute.myKey)
# return "property" of complex-attribute element on index 5
:read-attribute(name=complex-attribute[5].property)
# return object of complex-attribute element on index 5
:read-attribute(name=complex-attribute[5])
Comments