@Override public IRubyObject dup() { try { MapJavaProxy proxy = new MapJavaProxy(getRuntime(), metaClass); Map newMap = (Map)getObject().getClass().newInstance(); newMap.putAll((Map)getObject()); proxy.setObject(newMap); return proxy; } catch (InstantiationException ex) { throw getRuntime().newNotImplementedError("can't dup Map of type " + getObject().getClass().getName()); } catch (IllegalAccessException ex) { throw getRuntime().newNotImplementedError("can't dup Map of type " + getObject().getClass().getName()); } }
@Override public IRubyObject dup() { return dupImpl("dup"); }
private Map mapDelegate() { return receiver.getMapObject(); }
/** rb_hash_inspect * */ @JRubyMethod(name = "inspect") public IRubyObject inspect(ThreadContext context) { return getOrCreateRubyHashMap().inspect(context); }
public MapJavaProxy allocate(Ruby runtime, RubyClass klazz) { return new MapJavaProxy(runtime, klazz); } };
private RubyHashMap getOrCreateRubyHashMap() { if (wrappedMap == null) { wrappedMap = new RubyHashMap(getRuntime(), this); } // (JavaProxy)recv).getObject() might raise exception when // wrong number of args are given to the constructor. IRubyObject oldExc = getRuntime().getGlobalVariables().get("$!"); // Save $! try { wrappedMap.setSize( getMapObject().size() ); } catch (RaiseException e) { wrappedMap.setSize(0); getRuntime().getGlobalVariables().set("$!", oldExc); // Restore $! } return wrappedMap; }
MapJavaProxy.createMapJavaProxy(context);
private RubyHashMap getOrCreateRubyHashMap() { if (wrappedMap == null) { wrappedMap = new RubyHashMap(getRuntime(), this); } // (JavaProxy)recv).getObject() might raise exception when // wrong number of args are given to the constructor. try { wrappedMap.setSize(((Map)((JavaProxy)this).getObject()).size()); } catch (RaiseException e) { wrappedMap.setSize(0); } return wrappedMap; }
final Map getMapObject() { return (Map) getObject(); }
/** rb_hash_to_a * */ @JRubyMethod(name = "to_a") public RubyArray to_a() { return getOrCreateRubyHashMap().to_a(); }
public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new MapJavaProxy(runtime, klazz); } });
private RubyHashMap getOrCreateRubyHashMap() { if (wrappedMap == null) { wrappedMap = new RubyHashMap(getRuntime(), this); } // (JavaProxy)recv).getObject() might raise exception when // wrong number of args are given to the constructor. IRubyObject oldExc = getRuntime().getGlobalVariables().get("$!"); // Save $! try { wrappedMap.setSize( getMapObject().size() ); } catch (RaiseException e) { wrappedMap.setSize(0); getRuntime().getGlobalVariables().set("$!", oldExc); // Restore $! } return wrappedMap; }
MapJavaProxy.createMapJavaProxy(context);
private RubyHashMap getOrCreateRubyHashMap() { if (wrappedMap == null) { wrappedMap = new RubyHashMap(getRuntime(), this); } // (JavaProxy)recv).getObject() might raise exception when // wrong number of args are given to the constructor. try { wrappedMap.setSize(((Map)((JavaProxy)this).getObject()).size()); } catch (RaiseException e) { wrappedMap.setSize(0); } return wrappedMap; }
final Map getMapObject() { return (Map) getObject(); }
@Override public IRubyObject rbClone() { try { MapJavaProxy proxy = new MapJavaProxy(getRuntime(), metaClass); Map newMap = (Map)getObject().getClass().newInstance(); newMap.putAll((Map)getObject()); proxy.setObject(newMap); return proxy; } catch (InstantiationException ex) { throw getRuntime().newNotImplementedError("can't clone Map of type " + getObject().getClass().getName()); } catch (IllegalAccessException ex) { throw getRuntime().newNotImplementedError("can't clone Map of type " + getObject().getClass().getName()); } }
/** rb_hash_to_s * */ @JRubyMethod(name = "to_s") public IRubyObject to_s(ThreadContext context) { return getOrCreateRubyHashMap().to_s(context); }
public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new MapJavaProxy(runtime, klazz); } });
MapJavaProxy.createMapJavaProxy(runtime);
@Override public IRubyObject rbClone() { return dupImpl("clone"); }