public Collection extraSpecificImports() { Collection col = super.extraSpecificImports(); col.add( indirectorClassName ); col.add( "com.mchange.v2.ser.IndirectlySerialized" ); col.add( "com.mchange.v2.ser.Indirector" ); col.add( "com.mchange.v2.ser.SerializableUtils" ); col.add( "java.io.NotSerializableException" ); return col; }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { super.generate( info, superclassType, props, propTypes, iw); writeExtraDeclarations( info, superclassType, props, propTypes, iw); }
writeStoreObject( prop, propType, iw ); generateExtraSerWriteStatements( info, superclassType, props, propTypes, iw); iw.downIndent(); iw.println("}"); writeUnstoreObject( prop, propType, iw ); generateExtraSerInitializers( info, superclassType, props, propTypes, iw); iw.println("break;"); iw.downIndent();
g.addExtension( new SerializableExtension() ); g.generate(info, props, fw ); fw.flush();
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT || policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("Object o = ois.readObject();"); iw.println("if (o instanceof IndirectlySerialized) o = ((IndirectlySerialized) o).getObject();"); iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") o;"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeUnstoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT) writeIndirectStoreObject( prop, propType, iw ); else if (policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("//test serialize"); iw.println("SerializableUtils.toByteArray(" + prop.getName() + ");"); super.writeStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (NotSerializableException nse)"); iw.println("{"); iw.upIndent(); writeIndirectStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeStoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
writeStoreObject( prop, propType, iw ); generateExtraSerWriteStatements( info, superclassType, props, propTypes, iw); iw.downIndent(); iw.println("}"); writeUnstoreObject( prop, propType, iw ); generateExtraSerInitializers( info, superclassType, props, propTypes, iw); iw.println("break;"); iw.downIndent();
g.addExtension( new SerializableExtension() ); g.generate(info, props, fw ); fw.flush();
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT || policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("Object o = ois.readObject();"); iw.println("if (o instanceof IndirectlySerialized) o = ((IndirectlySerialized) o).getObject();"); iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") o;"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeUnstoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT) writeIndirectStoreObject( prop, propType, iw ); else if (policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("//test serialize"); iw.println("SerializableUtils.toByteArray(" + prop.getName() + ");"); super.writeStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (NotSerializableException nse)"); iw.println("{"); iw.upIndent(); writeIndirectStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeStoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
writeStoreObject( prop, propType, iw ); generateExtraSerWriteStatements( info, superclassType, props, propTypes, iw); iw.downIndent(); iw.println("}"); writeUnstoreObject( prop, propType, iw ); generateExtraSerInitializers( info, superclassType, props, propTypes, iw); iw.println("break;"); iw.downIndent();
g.addExtension( new SerializableExtension() ); g.generate(info, props, fw ); fw.flush();
public Collection extraSpecificImports() { Collection col = super.extraSpecificImports(); col.add( indirectorClassName ); col.add( "com.mchange.v2.ser.IndirectlySerialized" ); col.add( "com.mchange.v2.ser.Indirector" ); col.add( "com.mchange.v2.ser.SerializableUtils" ); col.add( "java.io.NotSerializableException" ); return col; }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { super.generate( info, superclassType, props, propTypes, iw); writeExtraDeclarations( info, superclassType, props, propTypes, iw); }
protected void writeUnstoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT || policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("// we create an artificial scope so that we can use the name o for all indirectly serialized objects."); iw.println("{"); iw.upIndent(); iw.println("Object o = ois.readObject();"); iw.println("if (o instanceof IndirectlySerialized) o = ((IndirectlySerialized) o).getObject();"); iw.println("this." + prop.getName() + " = (" + prop.getSimpleTypeName() + ") o;"); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeUnstoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected void writeStoreObject( Property prop, Class propType, IndentedWriter iw ) throws IOException { IndirectPolicy policy = indirectingPolicy( prop, propType ); if (policy == IndirectPolicy.DEFINITELY_INDIRECT) writeIndirectStoreObject( prop, propType, iw ); else if (policy == IndirectPolicy.INDIRECT_ON_EXCEPTION) { iw.println("try"); iw.println("{"); iw.upIndent(); iw.println("//test serialize"); iw.println("SerializableUtils.toByteArray(" + prop.getName() + ");"); super.writeStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); iw.println("catch (NotSerializableException nse)"); iw.println("{"); iw.upIndent(); writeIndirectStoreObject( prop, propType, iw ); iw.downIndent(); iw.println("}"); } else if (policy == IndirectPolicy.DEFINITELY_DIRECT) super.writeStoreObject( prop, propType, iw ); else throw new InternalError("indirectingPolicy() overridden to return unknown policy: " + policy); }
protected PropertyBeanGenerator createInnerGenerator() { SimplePropertyBeanGenerator innerGenerator = new SimplePropertyBeanGenerator(); innerGenerator.setInner( true ); innerGenerator.addExtension( new SerializableExtension() ); CloneableExtension ce = new CloneableExtension(); ce.setExceptionSwallowing( true ); innerGenerator.addExtension( ce ); return innerGenerator; }
public Collection extraSpecificImports() { Collection col = super.extraSpecificImports(); col.add( indirectorClassName ); col.add( "com.mchange.v2.ser.IndirectlySerialized" ); col.add( "com.mchange.v2.ser.Indirector" ); col.add( "com.mchange.v2.ser.SerializableUtils" ); col.add( "java.io.NotSerializableException" ); return col; }
public void generate(ClassInfo info, Class superclassType, Property[] props, Class[] propTypes, IndentedWriter iw) throws IOException { super.generate( info, superclassType, props, propTypes, iw); writeExtraDeclarations( info, superclassType, props, propTypes, iw); }
protected PropertyBeanGenerator createInnerGenerator() { SimplePropertyBeanGenerator innerGenerator = new SimplePropertyBeanGenerator(); innerGenerator.setInner( true ); innerGenerator.addExtension( new SerializableExtension() ); CloneableExtension ce = new CloneableExtension(); ce.setExceptionSwallowing( true ); innerGenerator.addExtension( ce ); return innerGenerator; }