boolean inNewExpr) throws ScriptException {
if (args.length == 1) {
if (args[0] instanceof Resource && !(args[0] instanceof Scriptable)) {
return new ResourceHostObject((Resource) args[0], cx);
} else if (args[0] instanceof Scriptable) {
throw new ScriptException("Resource object cannot be initialized directly, " +
"use registry.newResource() instead");
} else {
throw new ScriptException("Invalid argument type for Resource constructor");
}
} else {
throw new ScriptException("Resource object cannot be initialized directly, use " +
"registry.newResource() instead");
}
}