@JSFunction public static void log(Context cx, Scriptable thisObj, Object[] args, Function funObj) { log(args); }
@JSGetter("interfaceVersion") @SuppressWarnings("unused") public String getInterfaceVersion() { return INTERFACE_VERSION; }
propName = ((JSGetter) annotation).value(); if (propName == null || propName.length() == 0) { if (methodName.length() > 3 && methodName.startsWith("get")) { propName = ((JSFunction) annotation).value(); } else if (annotation instanceof JSStaticFunction) { propName = ((JSStaticFunction) annotation).value();
private static Method findSetterMethod(Method[] methods, String name, String prefix) { String newStyleName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1); for (Method method : methods) { JSSetter annotation = method.getAnnotation(JSSetter.class); if (annotation != null) { if (name.equals(annotation.value()) || ("".equals(annotation.value()) && newStyleName.equals(method.getName()))) { return method; } } } String oldStyleName = prefix + name; for (Method method : methods) { if (oldStyleName.equals(method.getName())) { return method; } } return null; }
@JSConstructor @SuppressWarnings("unused") public static Object construct(Context cx, Object[] args, Function ctorObj, boolean inNewExpr) { if (!inNewExpr) { return cx.newObject(ctorObj, CLASS_NAME, args); } String code = stringArg(args, 0); String fileName = stringArg(args, 1, "anonymous"); ScriptImpl self = new ScriptImpl(); self.script = cx.compileString(code, fileName, 1, null); return self; }
propName = ((JSGetter) annotation).value(); if (propName == null || propName.length() == 0) { if (methodName.length() > 3 && methodName.startsWith("get")) { propName = ((JSFunction) annotation).value(); } else if (annotation instanceof JSStaticFunction) { propName = ((JSStaticFunction) annotation).value();
private static Method findSetterMethod(Method[] methods, String name, String prefix) { String newStyleName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1); for (Method method : methods) { JSSetter annotation = method.getAnnotation(JSSetter.class); if (annotation != null) { if (name.equals(annotation.value()) || ("".equals(annotation.value()) && newStyleName.equals(method.getName()))) { return method; } } } String oldStyleName = prefix + name; for (Method method : methods) { if (oldStyleName.equals(method.getName())) { return method; } } return null; }
@JSFunction @SuppressWarnings("unused") public static Object getGlobal(Context cx, Scriptable thisObj, Object[] args, Function funObj) { ContextImpl self = (ContextImpl)thisObj; return self.globalProxy; } }
@JSConstructor public static Object init(Context cx, Object[] args, Function ctorObj, boolean inNewExpr) { String from = stringArg(args, 0); String to = stringArg(args, 1); IconvImpl self = new IconvImpl(); try { self.converter = new CharsetConverter(from, to); } catch (IllegalArgumentException ia) { throw Utils.makeError(cx, ctorObj, "Invalid character set", Constants.EINVAL); } return self; }
propName = ((JSGetter) annotation).value(); if (propName == null || propName.length() == 0) { if (methodName.length() > 3 && methodName.startsWith("get")) { propName = ((JSFunction) annotation).value(); } else if (annotation instanceof JSStaticFunction) { propName = ((JSStaticFunction) annotation).value();
private static Method findSetterMethod(Method[] methods, String name, String prefix) { String newStyleName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1); for (Method method : methods) { JSSetter annotation = method.getAnnotation(JSSetter.class); if (annotation != null) { if (name.equals(annotation.value()) || ("".equals(annotation.value()) && newStyleName.equals(method.getName()))) { return method; } } } String oldStyleName = prefix + name; for (Method method : methods) { if (oldStyleName.equals(method.getName())) { return method; } } return null; }
@JSFunction @SuppressWarnings("unused") public static void reset(Context cx, Scriptable thisObj, Object[] args, Function func) { JdbcConnection self = (JdbcConnection)thisObj; if (log.isDebugEnabled()) { log.debug("Resetting {} to be re-pooled", self.conn); } try { synchronized (self) { self.conn.setAutoCommit(true); } } catch (SQLException sqle) { if (log.isDebugEnabled()) { log.debug("Error on reset -- ignoring! {}", sqle); } } }
propName = ((JSGetter) annotation).value(); if (propName == null || propName.length() == 0) { if (methodName.length() > 3 && methodName.startsWith("get")) { propName = ((JSFunction) annotation).value(); } else if (annotation instanceof JSStaticFunction) { propName = ((JSStaticFunction) annotation).value();
@JSFunction @SuppressWarnings("unused") public static void setAutoCommit(Context cx, Scriptable thisObj, Object[] args, Function func) { boolean auto = booleanArg(args, 0); JdbcConnection self = (JdbcConnection)thisObj; try { synchronized (self) { self.conn.setAutoCommit(auto); } } catch (SQLException sqle) { if (log.isDebugEnabled()) { log.debug("Error on setAutoCommit -- ignoring! {}", sqle); } } }
@JSFunction @SuppressWarnings("unused") public static Object runInContext(Context cx, Scriptable thisObj, Object[] args, Function funObj) { ContextImpl ctx = objArg(args, 0, ContextImpl.class, true); ScriptImpl self = (ScriptImpl)thisObj; return self.script.exec(cx, ctx.globalProxy); } }
@JSFunction @SuppressWarnings("unused") public static void setTransformer(Context cx, Scriptable thisObj, Object[] args, Function funObj) { String className = stringArg(args, 0); XmlWrapImpl self = (XmlWrapImpl)thisObj; self.transFactory = TransformerFactory.newInstance(className, XmlWrap.class.getClassLoader()); self.configureTransformer(cx); }
@JSFunction public static Object encodingExists(Context cx, Scriptable thisObj, Object[] args, Function funObj) { String encoding = stringArg(args, 0); return Context.javaToJS(Charset.isSupported(encoding), funObj); }
@JSFunction @SuppressWarnings("unused") public static Object run(Context cx, Scriptable thisObj, Object[] args, Function funObj) { String code = stringArg(args, 0); String fileName = stringArg(args, 1, "anonymous"); ContextImpl self = (ContextImpl)thisObj; return cx.evaluateString(self.globalProxy, code, fileName, 1, null); }
@JSFunction @SuppressWarnings("unused") public static void rollback(Context cx, Scriptable thisObj, Object[] args, Function func) { final Function cb = functionArg(args, 0, true); final JdbcConnection self = (JdbcConnection)thisObj; final Object domain = self.runtime.getDomain(); self.runtime.getAsyncPool().execute(new Runnable() { @Override public void run() { try { synchronized (self) { self.conn.rollback(); } self.runtime.enqueueCallback(cb, cb, self, ScriptRuntime.emptyArgs); } catch (SQLException sqle) { self.returnError(cb, domain, sqle); } } }); }
@JSFunction @SuppressWarnings("unused") public static Object createDocument(Context cx, Scriptable thisObj, Object[] args, Function funObj) { ensureArg(args, 0); XmlWrapImpl self = (XmlWrapImpl)thisObj; Source src = self.getSource(cx, args[0]); ScriptableObject ret = (ScriptableObject)cx.newObject(thisObj); ret.associateValue("document", src); return ret; }