1 19 20 import java.io.File ; 21 import java.io.FileInputStream ; 22 import java.io.FileOutputStream ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 26 import samples.doml.*; 28 import samples.doml.Package; 29 30 35 public class TestPrototype { 36 37 static class ClassImplPrototype extends ClassImpl { 38 private static int i = 0; 39 protected Object clone() throws CloneNotSupportedException { 41 ClassImpl ret = (ClassImpl)super.clone(); 42 ret.setName("Class_"+(i++)); 43 return ret; 44 } 45 } 46 47 public static void main(String [] args) { 48 try { 49 ClassImpl.setPrototype(new ClassImplPrototype()); 51 52 Doml root = DomlImpl.newInstance(); 53 Vendor v = VendorImpl.newInstance(); 54 Package pkg = PackageImpl.newInstance(); 55 56 root.setVendor(v); 57 v.setXmlpackage(pkg); 58 pkg.addXmlclass(ClassImpl.newInstance()); 60 pkg.addXmlclass(ClassImpl.newInstance()); 61 pkg.addXmlclass(ClassImpl.newInstance()); 62 63 root.marshal(System.out); 64 65 } catch (Exception e) { 66 e.printStackTrace(); 67 } 68 } 69 } 70 | Popular Tags |