}
protected Object getValueBody( ExprContext context, Object source ) throws ExprException
{
Object result = null;
OrderedList listProto = OrderedList.get(source);
// int indexType = getIndexedPropertyType(context, source);
Object index = getProperty(context, source);
if (index instanceof DynamicSubscript) {
Object array = source;
int len = listProto.size(array);
switch (((DynamicSubscript)index).getFlag()) {
case DynamicSubscript.ALL:
return listProto.copy(array);
case DynamicSubscript.FIRST:
index = new Integer((len > 0) ? 0 : -1);
break;
case DynamicSubscript.MID:
index = new Integer((len > 0) ? (len / 2) : -1);
break;
case DynamicSubscript.LAST:
index = new Integer((len > 0) ? (len - 1) : -1);
break;
}
} else {
Assert.that(index instanceof Number, "array subscript must be number");
// if (indexType == ExprRuntime.INDEXED_PROPERTY_OBJECT) {
// throw new ExprException("DynamicSubscript '" + this + "' not allowed for object indexed property '" + source + "'");
}
try {
Object value = listProto.elementAt(source, ((Number)index).intValue());
return ExprRuntime.convert(value);
}
catch (IndexOutOfBoundsException e) {
// If there is no element, return null
return null;