Data Structures
Array Literal, List Literal, Set Literal, Map literal
syntax: https://commons.apache.org/proper/commons-jexl/reference/syntax.html
Array Literal
An array is a fixed-size, contiguous memory structure that stores elements of the same type.
Syntax
A
[
followed by zero or more expressions separated by,
and ending with]
, e.g.[ 1, 2, "three" ]
This syntax creates an
Object[]
.Empty array literal can be specified as
[]
with result of creatingObject[]
JEXL will attempt to strongly type the array; if all entries are of the same class or if all entries are Number instance, the array literal will be an
MyClass[]
in the former case, aNumber[]
in the latter case.Furthermore, if all entries in the array literal are of the same class and that class has an equivalent primitive type, the array returned will be a primitive array. e.g.
[1, 2, 3]
will be interpreted asint[]
.
Methods
size() -> Integer
: Returns the number of elements in the array.get(index: Integer) -> T
: Retrieves the element at the specifiedindex
and returns it.set(index: Integer, value: T)
: Sets the value of the element at the givenindex
.
Usage
List Literal
A list is a dynamic array-like data structure that can grow or shrink and allows storage of elements of different types.
Syntax
A
[
followed by zero or more expressions separated by,
and ending with,...]
, e.g.[ 1, 2, "three",...]
This syntax creates an
ArrayList<Object>
.Empty list literal can be specified as
[...]
Methods
add(value: T)
: Adds a new element with the provided value to the array.remove(index: Integer)
: Removes the element at the specifiedindex
.remove(value: T)
: Removes the first occurrence of the element with the specifiedvalue
.clear()
: Clears all elements from the array.size(): Integer
Returns the number of elements in the list.isEmpty():
Boolean Checks if the list is empty and returnstrue
if it has no elements; otherwise, it returnsfalse
.static of(): List<T>
Creates and returns an empty list.This class allows you to create and manage lists with elements of a specific data type.contains(Object o): Boolean
- Returns boolean depending on whether list contains specified parameter.toArray()
- convert List to Array Data Structure
Usage
Map Literal
A map represented as HashMap<Object, Object>
, is a collection that associates unique keys with corresponding values, facilitating efficient retrieval and modification of data based on key references.
HashMaps are especially useful for defining a row in SuiteTable
Syntax
A
{
followed by zero or more sets ofkey : value
pairs separated by,
and ending with}
, e.g.{ "one" : 1, "two" : 2, "three" : 3, "more": "many more" }
This syntax creates a
HashMap<Object,Object>
.Empty map literal can be specified as
{:}
Methods
create(); Map
Creates an empty map and returns it.
add(Map<String, Object> map, String key, Object value): void
adds a key-value pair to map. Returns nothing
size(); Integer
Returns number of key-value pairs in map.
isEmpty: Boolean
Returns true of map is empty, otherwise returns false.
cotainsKey(Object key): Boolean
Returns true if map contains specified key, otherwise returns false.
containsValue(Object value): Boolean
Returns true if map contains specified value, otherwise returns false.
remove(String key): Object
Removes key from Map and returns the remove value object.
keySet(); and values();
Return the keys and values of the map, respectively.
Usage
Or you can define map Manually: