/** * Returns a new proxy instance of a type corresponding to rawJavaObject's class, * or the cached proxy if we've already seen this object. Note that primitives * and strings are <em>not</em> coerced to corresponding Ruby types; use * JavaUtil.convertJavaToUsableRubyObject to get coerced types or proxies as * appropriate. * * @param runtime the JRuby runtime * @param rawJavaObject the object to get a wrapper for * @param forceCache whether to force the use of the proxy cache * @return the new (or cached) proxy for the specified Java object * @see JavaUtil#convertJavaToUsableRubyObject */ public static IRubyObject getInstance(Ruby runtime, Object rawJavaObject, boolean forceCache) { if (rawJavaObject != null) { RubyClass proxyClass = (RubyClass) getProxyClass(runtime, rawJavaObject.getClass()); if (OBJECT_PROXY_CACHE || forceCache || proxyClass.getCacheProxy()) { return runtime.getJavaSupport().getObjectProxyCache().getOrCreate(rawJavaObject, proxyClass); } return allocateProxy(rawJavaObject, proxyClass); } return runtime.getNil(); }
/** * Returns a new proxy instance of a type corresponding to rawJavaObject's class, * or the cached proxy if we've already seen this object. Note that primitives * and strings are <em>not</em> coerced to corresponding Ruby types; use * JavaUtil.convertJavaToUsableRubyObject to get coerced types or proxies as * appropriate. * * @param runtime the JRuby runtime * @param rawJavaObject the object to get a wrapper for * @param forceCache whether to force the use of the proxy cache * @return the new (or cached) proxy for the specified Java object * @see JavaUtil#convertJavaToUsableRubyObject */ public static IRubyObject getInstance(Ruby runtime, Object rawJavaObject, boolean forceCache) { if (rawJavaObject != null) { RubyClass proxyClass = (RubyClass) getProxyClass(runtime, rawJavaObject.getClass()); if (OBJECT_PROXY_CACHE || forceCache || proxyClass.getCacheProxy()) { return runtime.getJavaSupport().getObjectProxyCache().getOrCreate(rawJavaObject, proxyClass); } return allocateProxy(rawJavaObject, proxyClass); } return runtime.getNil(); }
/** * Returns a new proxy instance of a type corresponding to rawJavaObject's class, * or the cached proxy if we've already seen this object. Note that primitives * and strings are <em>not</em> coerced to corresponding Ruby types; use * JavaUtil.convertJavaToUsableRubyObject to get coerced types or proxies as * appropriate. * * @param runtime the JRuby runtime * @param rawJavaObject the object to get a wrapper for * @param forceCache whether to force the use of the proxy cache * @return the new (or cached) proxy for the specified Java object * @see JavaUtil#convertJavaToUsableRubyObject */ public static IRubyObject getInstance(Ruby runtime, Object rawJavaObject, boolean forceCache) { if (rawJavaObject != null) { RubyClass proxyClass = (RubyClass) getProxyClass(runtime, rawJavaObject.getClass()); if (OBJECT_PROXY_CACHE || forceCache || proxyClass.getCacheProxy()) { return runtime.getJavaSupport().getObjectProxyCache().getOrCreate(rawJavaObject, proxyClass); } else { return allocateProxy(rawJavaObject, proxyClass); } } return runtime.getNil(); }
/** * Returns a new proxy instance of a type corresponding to rawJavaObject's class, * or the cached proxy if we've already seen this object. Note that primitives * and strings are <em>not</em> coerced to corresponding Ruby types; use * JavaUtil.convertJavaToUsableRubyObject to get coerced types or proxies as * appropriate. * * @param runtime the JRuby runtime * @param rawJavaObject the object to get a wrapper for * @param forceCache whether to force the use of the proxy cache * @return the new (or cached) proxy for the specified Java object * @see JavaUtil#convertJavaToUsableRubyObject */ public static IRubyObject getInstance(Ruby runtime, Object rawJavaObject, boolean forceCache) { if (rawJavaObject != null) { RubyClass proxyClass = (RubyClass) getProxyClass(runtime, rawJavaObject.getClass()); if (OBJECT_PROXY_CACHE || forceCache || proxyClass.getCacheProxy()) { return runtime.getJavaSupport().getObjectProxyCache().getOrCreate(rawJavaObject, proxyClass); } else { return allocateProxy(rawJavaObject, proxyClass); } } return runtime.getNil(); }