return new FtpObject(args[0].toString());
}
public static void init(Scriptable scope) {
Method[] methods = FtpObject.class.getDeclaredMethods();
ScriptableObject proto = new FtpObject();
proto.setPrototype(getObjectPrototype(scope));
Member ctorMember = null;
for (int i=0; i<methods.length; i++) {
if ("ftpObjCtor".equals(methods[i].getName())) {
ctorMember = methods[i];
break;
}
}
FunctionObject ctor = new FunctionObject("FtpClient", ctorMember, scope);
ctor.addAsConstructor(scope, proto);
String[] ftpFuncs = {
"login", "cd", "mkdir", "lcd", "putFile",
"putString", "getFile", "getString", "logout",
"binary", "ascii"
};
try {
proto.defineFunctionProperties(ftpFuncs, FtpObject.class, 0);
} catch (Exception ignore) {
System.err.println ("Error defining function properties: "+ignore);
}
}