use of com.scratchdisk.list.List in project scriptographer by scriptographer.
the class ListWrapper method coerceComponentType.
private Object coerceComponentType(Object value) {
Object unwrapped = value;
if (unwrapped instanceof Wrapper)
unwrapped = ((Wrapper) unwrapped).unwrap();
Class type = ((List) javaObject).getComponentType();
// Use WrapFactory to coerce type if not compatible
return type.isInstance(unwrapped) ? unwrapped : Context.getCurrentContext().getWrapFactory().coerceType(type, value, unwrapped);
}
use of com.scratchdisk.list.List in project scriptographer by scriptographer.
the class ListWrapper method put.
@SuppressWarnings("unchecked")
public void put(int index, Scriptable start, Object value) {
if (javaObject != null && javaObject instanceof List) {
List list = ((List) javaObject);
int size = list.size();
value = coerceComponentType(value);
if (index >= size) {
for (int i = size; i < index; i++) list.add(i, null);
list.add(index, value);
} else {
list.set(index, value);
}
if (changeReceiver != null)
updateChangeReceiver();
}
}
Aggregations