public class BasicArrayValue extends AbstractRightValue
Constructor and Description |
---|
BasicArrayValue()
This constructor can be used by extension classes to instantiate a new
BasicArrayValue when the extension function does not have access to the
interpreter.
|
BasicArrayValue(ExtendedInterpreter interpreter)
Create a new BasicArrayValue and remember the interpreter.
|
Modifier and Type | Method and Description |
---|---|
Object |
get(Integer index)
Get the
index -th element of the array. |
Long |
getLength()
Get the length of the array.
|
void |
set(Integer index,
Object object)
Set the index-th element of the array
|
void |
setArray(Object[] array)
Set the array object.
|
void |
setInterpreter(ExtendedInterpreter interpreter)
Set the interpreter that this array belongs to.
|
isArray, isBoolean, isDouble, isJavaObject, isLong, isNumeric, isString
public BasicArrayValue()
Note that in later versions this constructor will be deprecated as soon as the interface of the extensions will make it possible to pass the interpreter along to the extension methods.
public BasicArrayValue(ExtendedInterpreter interpreter)
The interpreter can determine the maximum size allowed for arrays and therefore may suggest for a BasicArrayValue not to extend its size, but rather throw exception. This is to prevent allocating extraordinary large arrays in an interpreter by mistake.
interpreter
- public void setArray(Object[] array)
set(Integer, Object)
.array
- the arrayNullPointerException
- when the array is nullpublic void setInterpreter(ExtendedInterpreter interpreter)
Note that this method is used only from the code where the interpreter calls an extension method that returns a BasicArrayValue. In that case the parameter less constructor of this class is called by the extension method and thus the BasicArrayValue does not know the interpreter and can not request suggestion from the interpreter to perform resizing or throw exception.
When the parameterless version of the constructor becomes deprecated this setter will also become deprecated.
interpreter
- public Long getLength()
public void set(Integer index, Object object) throws ExecutionException
index
- object
- the new value for the arrayExecutionException
public Object get(Integer index) throws ExecutionException
index
-th element of the array. Note that this method does
NOT convert the value to an ordinary Java object. Thus when calling this
method from an extension method be prepared to convert the value to
ordinary Java object yourself.index
- ExecutionException
Copyright © 2013 Verhas and Verhas Software Craftsmen. All Rights Reserved.