@Override public TemplateModel wrap(Object obj) throws TemplateModelException { // So our existence builtins work as expected. if (obj == UNDEFINED_INSTANCE || obj == UniqueTag.NOT_FOUND) { return null; } // UniqueTag.NULL_VALUE represents intentionally set null in Rhino, and // BeansWrapper#nullModel also represents intentionally returned null. // I [A.Sz.] am fairly certain that this value is never passed out of // any of the Rhino code back to clients, but is instead always being // converted back to null. However, since this object is available to // any 3rd party Scriptable implementations as well, they might return // it, so we'll just be on the safe side, and handle it. if (obj == UniqueTag.NULL_VALUE) { return super.wrap(null); } // So, say, a JavaAdapter for FreeMarker interfaces works if (obj instanceof Wrapper) { obj = ((Wrapper) obj).unwrap(); } return super.wrap(obj); }
/** * Unwrap a Rhino object (getting the raw java object) and convert undefined to null */ public static Object unwrap(Object obj) { if (obj instanceof Wrapper) { obj = ((Wrapper)obj).unwrap(); } else if (obj == Undefined.instance) { obj = null; } return obj; }
protected Object unwrapReturnValue(Object result) { if (result instanceof Wrapper) { result = ((Wrapper) result).unwrap(); } return result instanceof Undefined ? null : result; }
protected Object unwrappedValue(Object val) { if (val != null && val instanceof Wrapper) { val = ((Wrapper) val).unwrap(); } return val; }
private static Object unwrap(Object obj) { if (obj instanceof Wrapper) { obj = ((Wrapper)obj).unwrap(); } else if (obj == Undefined.instance) { obj = null; } return obj; }
private static Object unwrap(Object obj) { if (obj instanceof Wrapper) { obj = ((Wrapper)obj).unwrap(); } else if (obj == Undefined.instance) { obj = null; } return obj; }
private static OutputStream toOutputStream(Object value) { OutputStream os = null; if (value instanceof Wrapper) { Object unwrapped = ((Wrapper)value).unwrap(); if (unwrapped instanceof OutputStream) { os = (OutputStream)unwrapped; } } return os; }
@Override public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return cls.isInstance(instance); }
@Override public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return cls.isInstance(instance); }
ResolvedOverload(Object[] args, int index) { this.index = index; types = new Class<?>[args.length]; for (int i = 0, l = args.length; i < l; i++) { Object arg = args[i]; if (arg instanceof Wrapper) arg = ((Wrapper)arg).unwrap(); types[i] = arg == null ? null : arg.getClass(); } }
public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return Map.class.isInstance(instance); }
public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return Map.class.isInstance(instance); }
@Override public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return cls.isInstance(instance); }
ResolvedOverload(Object[] args, int index) { this.index = index; types = new Class<?>[args.length]; for (int i = 0, l = args.length; i < l; i++) { Object arg = args[i]; if (arg instanceof Wrapper) arg = ((Wrapper)arg).unwrap(); types[i] = arg == null ? null : arg.getClass(); } }
public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return cls.isInstance(instance); }
@Override public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return cls.isInstance(instance); }
public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return Map.class.isInstance(instance); }
public boolean hasInstance(Scriptable value) { if (!(value instanceof Wrapper)) return false; Object instance = ((Wrapper)value).unwrap(); return Map.class.isInstance(instance); }
ResolvedOverload(Object[] args, int index) { this.index = index; types = new Class<?>[args.length]; for (int i = 0, l = args.length; i < l; i++) { Object arg = args[i]; if (arg instanceof Wrapper) arg = ((Wrapper)arg).unwrap(); types[i] = arg == null ? null : arg.getClass(); } }
/** * @see org.mozilla.javascript.Function#call */ @Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { synchronized(thisObj instanceof Wrapper ? ((Wrapper)thisObj).unwrap() : thisObj) { return ((Function)obj).call(cx,scope,thisObj,args); } } }