List of utility methods to do Javascript Mozilla Library
String | getFunctionArgsString(FunctionNode fn) Iterates through a function's parameters and returns a string representation of them, suitable for presentation as part of the method's signature. StringBuilder sb = new StringBuilder("("); int paramCount = fn.getParamCount(); if (paramCount > 0) { List<AstNode> fnParams = fn.getParams(); for (int i = 0; i < paramCount; i++) { String paramName = null; AstNode paramNode = fnParams.get(i); switch (paramNode.getType()) { ... |
Context | getGlobalContextForValidation() get Global Context For Validation Context context = Context.enter();
context.setOptimizationLevel(-1);
return context;
|
Object | getJavaObject(Scriptable scope, String name) get Java Object NativeJavaObject objWrapper = (NativeJavaObject) scope.get(name, null);
return objWrapper.unwrap();
|
Scriptable | getJsArray(Scriptable scope, Vector> v) get Js Array List<Object> list = new ArrayList<Object>(); for (int i = 0; i < v.size(); i++) { if (v.get(i) != null) list.add(Context.toObject(v.get(i), scope)); Context cx = Context.getCurrentContext(); return cx.newArray(scope, list.toArray()); |
Map,?> | getMapArgument(Object[] args, int pos) Get an argument as Map if (pos >= args.length || args[pos] == null || args[pos] == Undefined.instance) return null; if (args[pos] instanceof Map<?, ?>) return (Map<?, ?>) args[pos]; throw new IllegalArgumentException("Can't convert to java.util.Map: " + args[pos]); |
Object | getObjectArgument(Object[] args, int pos, Object defaultValue) Get an argument as object if (pos >= args.length || args[pos] == null || args[pos] == Undefined.instance) return defaultValue; return Context.jsToJava(args[pos], Object.class); |
Object | getProperty(Scriptable obj, final String prop) get Property while (obj != null) { final Object val = obj.get(prop, obj); if (val != Scriptable.NOT_FOUND) { return val; obj = obj.getPrototype(); throw new NoSuchFieldException(prop); ... |
String | getPropertyName(AstNode propKeyNode) Property keys in object literals can be identifiers or string literals. return (propKeyNode instanceof Name) ? ((Name) propKeyNode).getIdentifier() : ((StringLiteral) propKeyNode).getValue(); |
String | getPrototypeClazz(List get Prototype Clazz return getPrototypeClazz(nodes, -1);
|
ScriptableObject | getScriptableArgument(Object[] args, int pos, boolean allowNull) Get an argument as ScriptableObject if (pos >= args.length || args[pos] == null || args[pos] == Undefined.instance) { if (allowNull) return null; throw new IllegalArgumentException("Argument " + (pos + 1) + " must not be null"); if (args[pos] instanceof ScriptableObject) { return (ScriptableObject) args[pos]; throw new IllegalArgumentException("Can't convert to ScriptableObject: " + args[pos]); |