if (arguments.length == 0) {
try {
String[] children = ((Collection)collectionHostObject.getResource()).getChildren();
return cx.newArray(thisObj, Arrays.copyOf(children, children.length, Object[].class));
} catch (RegistryException e) {
throw new ScriptException("Error occurred while creating a new Resource.", e);
}
} else if (arguments.length == 2) {
if (arguments[0] instanceof Number && arguments[1] instanceof Number) {
try {
String[] children = ((Collection) collectionHostObject.getResource()).getChildren(
((Number) arguments[0]).intValue(),
((Number) arguments[1]).intValue());
return cx.newArray(thisObj, Arrays.copyOf(children, children.length, Object[].class));
} catch (RegistryException e) {
throw new ScriptException("Error occurred while creating a new Resource.", e);
}
} else {
throw new ScriptException("Invalid argument types for getChildren() method");
}
} else {
throw new ScriptException("Invalid no. of arguments for getChildren() method");
}
}