1 16 17 package org.apache.ws.jaxme.generator.sg.impl; 18 19 import java.io.Serializable ; 20 21 import org.apache.ws.jaxme.generator.SchemaReader; 22 import org.apache.ws.jaxme.generator.sg.SchemaSG; 23 import org.apache.ws.jaxme.js.JavaField; 24 import org.apache.ws.jaxme.js.JavaQName; 25 import org.apache.ws.jaxme.js.JavaQNameImpl; 26 import org.apache.ws.jaxme.js.JavaSource; 27 28 31 public class SerializableSG { 32 private static final JavaQName SERIALIZABLE_TYPE = JavaQNameImpl.getInstance(Serializable .class); 33 34 37 public static void makeSerializable(SchemaSG pSchema, JavaSource pSource) { 38 SchemaReader sr = pSchema.getFactory().getGenerator().getSchemaReader(); 39 if (sr instanceof JaxMeSchemaReader) { 40 JaxMeSchemaReader jsr = (JaxMeSchemaReader) sr; 41 XjcSerializable xjcSerializable = jsr.getXjcSerializable(); 42 if (xjcSerializable != null) { 43 if (!pSource.isImplementing(SERIALIZABLE_TYPE)) { 44 pSource.addImplements(SERIALIZABLE_TYPE); 45 } 46 if (xjcSerializable.getUid() != null) { 47 JavaField uid = pSource.newJavaField("serialVersionUID", JavaQNameImpl.LONG, JavaSource.PRIVATE); 48 uid.setStatic(true); 49 uid.setFinal(true); 50 uid.addLine(xjcSerializable.getUid()); 51 } 52 } 53 } 54 } 55 } 56 | Popular Tags |