var=array[1];Simkin for Java supports the array index feature in one of two ways:
For example, if array implements the Executable interface, the the following results in a call to setValueAt:
array[1]="foo";and this example results in a call to getValueAt:
var=array[1];
The script syntax allows for arbitrary expressions within the [ ], so for example the following are legal syntax:
var=array[1]; var=array["key"];If the underlying array is a native Java array, the interpreter will always convert the expression to a number, which is zero-based.
If the underlying object implements the Executable interface, the value is passed in "as-is" to setValueAt or getValueAt. This means that the underlying Java classes can expose collections which are keyed on any kind of value - so that ordinary Vectors, and Hashtables or Associative Arrays can all be supported.
Simkin is supplied with two classes which have array index support, TreeNodeObject and XMLElementObject. These both convert the array index to a numeric value before using it as an index into their collection. They also both assume the index is zero based. Both classes also support a field called numChildren which returns the number of elements in each collection.