/** * Object output stream decoration constructor. * * @param out * @throws IOException * @see ObjectOutputStream#ObjectOutputStream(OutputStream) */ public BukkitObjectOutputStream(OutputStream out) throws IOException { super(out); super.enableReplaceObject(true); }
/** * Constructor provided to mirror super functionality. * * @throws IOException * @throws SecurityException * @see ObjectOutputStream#ObjectOutputStream() */ protected BukkitObjectOutputStream() throws IOException, SecurityException { super(); super.enableReplaceObject(true); }
public JavaEEObjectOutputStream(OutputStream oos, boolean replaceObject, Collection<JavaEEObjectStreamHandler> handlers) throws IOException { super(oos); super.enableReplaceObject(replaceObject); this.handlers = handlers; }
/** * Object output stream decoration constructor. * * @param out * @throws IOException * @see ObjectOutputStream#ObjectOutputStream(OutputStream) */ public BukkitObjectOutputStream(OutputStream out) throws IOException { super(out); super.enableReplaceObject(true); }
public JavaEEObjectOutputStream(OutputStream oos, boolean replaceObject, Collection<JavaEEObjectStreamHandler> handlers) throws IOException { super(oos); super.enableReplaceObject(replaceObject); this.handlers = handlers; }
@Override public boolean enableReplaceObject(boolean enable) throws SecurityException { return super.enableReplaceObject(enable); } }
/** * Constructor provided to mirror super functionality. * * @throws IOException * @throws SecurityException * @see ObjectOutputStream#ObjectOutputStream() */ protected BukkitObjectOutputStream() throws IOException, SecurityException { super(); super.enableReplaceObject(true); }
public class SurrogateObjectOutputStream extends ObjectOutputStream { public SurrogateObjectOutputStream(OutputStream out) throws IOException { super(out); enableReplaceObject(true); } protected SurrogateObjectOutputStream() throws IOException, SecurityException { super(); enableReplaceObject(true); } @Override protected Object replaceObject(Object obj) throws IOException { if (obj instanceof Pojo) { return new PojoSurrogate((Pojo) obj); } else return super.replaceObject(obj); } }
public class SerializableLatLngOutputStream extends ObjectOutputStream { public SerializableLatLngOutputStream(OutputStream out) throws IOException { super(out); enableReplaceObject(true); } protected SerializableLatLngOutputStream() throws IOException, SecurityException { super(); enableReplaceObject(true); } @Override protected Object replaceObject(Object obj) throws IOException { if (obj instanceof LatLng) { return new SerializableLatLng((LatLng) obj); } else return super.replaceObject(obj); } }
public class SurrogateOutputStream extends ObjectOutputStream { public SurrogateOutputStream(OutputStream out) throws IOException { super(out); enableReplaceObject(true); } protected SurrogateOutputStream() throws IOException, SecurityException { super(); enableReplaceObject(true); } @Override protected Object replaceObject(Object obj) throws IOException { if (obj instanceof Area) { return new AreaSurrogate((Area) obj); } else { return super.replaceObject(obj); } } }
public class FooObjOutputStream extends ObjectOutputStream { public FooObjOutputStream(OutputStream out) throws IOException { super(out); enableReplaceObject(true); } protected FooObjOutputStream() throws IOException, SecurityException { super(); enableReplaceObject(true); } @Override protected Object replaceObject(Object obj) throws IOException { if (obj instanceof Foo) { return new FooState((Foo) obj); } else { return super.replaceObject(obj); } } }
public class MyOOS extends ObjectOutputStream { public MyOOS(OutputStream out) throws IOException { super(out); enableReplaceObject(true); } @Override protected Object replaceObject(Object obj) throws IOException { if ((obj instanceof Serializable)) return obj; System.err.println("Skipping serialization of "+obj); return null; } }
public class StringPooledObjectOutputStream extends ObjectOutputStream { private Map<String, String> stringPool = new HashMap<String, String>(); public StringPooledObjectOutputStream(OutputStream out) throws IOException { super(out); enableReplaceObject(true); } @Override protected Object replaceObject(Object obj) throws IOException { if( !(obj instanceof String) ) return super.replaceObject(obj); String str = (String)obj; String replacedStr = stringPool.get(str); if( replacedStr == null ){ replacedStr = (String)super.replaceObject(str); stringPool.put(replacedStr, replacedStr); } return replacedStr; } }
protected boolean enableReplaceObject(boolean enable) { try { if (enable == fieldEnableReplace.getBoolean(this)) { return enable; } fieldEnableReplace.setBoolean(this,enable); return !fieldEnableReplace.getBoolean(this); } catch (Exception e) { e.printStackTrace(); // trying the super method return super.enableReplaceObject(enable); } }