public static Object[] toNativeArray(Object o) throws PageException {
if(o instanceof Object[]) {
return (Object[])o;
}
else if(o instanceof Array) {
Array arr=(Array)o;
Object[] objs=new Object[arr.size()];
for(int i=0;i<objs.length;i++) {
objs[i]=arr.get(i+1, null);
}
return objs;
}
else if(o instanceof List) {
return ((List) o).toArray();
}
else if(o instanceof XMLStruct) {
XMLStruct sct=((XMLStruct)o);
if(sct instanceof XMLMultiElementStruct) return toNativeArray((sct));
Object[] a=new Object[1];
a[0]=sct;
return a;
}
else if(o instanceof ObjectWrap) {
return toNativeArray(((ObjectWrap)o).getEmbededObject());
}
else if(o instanceof Struct) {
Struct sct=(Struct) o;
Array arr=new ArrayImpl();
Iterator<Entry<Key, Object>> it = sct.entryIterator();
Entry<Key, Object> e=null;
try {
while(it.hasNext()) {
e=it.next();
arr.setE(toIntValue(e.getKey().getString()),e.getValue());
}
}
catch (ExpressionException ee) {
throw new ExpressionException("can't cast struct to a array, key ["+e.getKey()+"] is not a number");
}