1 19 35 36 package org.netbeans.modules.j2ee.sun.share.plan; 37 38 import org.w3c.dom.*; 39 import org.netbeans.modules.schema2beans.*; 40 import java.beans.*; 41 import java.util.*; 42 import java.io.*; 43 44 46 public class DeploymentPlan extends org.netbeans.modules.schema2beans.BaseBean 47 { 48 49 static Vector comparators = new Vector(); 50 private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(3, 6, 1); 51 52 static public final String FILE_ENTRY = "FileEntry"; 54 public DeploymentPlan() throws org.netbeans.modules.schema2beans.Schema2BeansException { 55 this(null, Common.USE_DEFAULT_VALUES); 56 } 57 58 public DeploymentPlan(org.w3c.dom.Node doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException { 59 this(Common.NO_DEFAULT_VALUES); 60 initFromNode(doc, options); 61 } 62 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException 63 { 64 if (doc == null) 65 { 66 doc = GraphManager.createRootElementNode("deployment-plan"); if (doc == null) 68 throw new Schema2BeansException(Common.getMessage( 69 "CantCreateDOMRoot_msg", "deployment-plan")); 70 } 71 Node n = GraphManager.getElementNode("deployment-plan", doc); if (n == null) 73 throw new Schema2BeansException(Common.getMessage( 74 "DocRootNotInDOMGraph_msg", "deployment-plan", doc.getFirstChild().getNodeName())); 75 76 this.graphManager.setXmlDocument(doc); 77 78 this.createBean(n, this.graphManager()); 80 this.initialize(options); 81 } 82 public DeploymentPlan(int options) 83 { 84 super(comparators, runtimeVersion); 85 initOptions(options); 86 } 87 protected void initOptions(int options) 88 { 89 this.graphManager = new GraphManager(this); 91 this.createRoot("deployment-plan", "DeploymentPlan", Common.TYPE_1 | Common.TYPE_BEAN, DeploymentPlan.class); 93 94 initPropertyTables(1); 96 this.createProperty("file-entry", FILE_ENTRY, 98 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 99 FileEntry.class); 100 this.initialize(options); 101 } 102 103 void initialize(int options) { 105 106 } 107 108 public void setFileEntry(int index, FileEntry value) { 110 this.setValue(FILE_ENTRY, index, value); 111 } 112 113 public FileEntry getFileEntry(int index) { 115 return (FileEntry)this.getValue(FILE_ENTRY, index); 116 } 117 118 public int sizeFileEntry() { 120 return this.size(FILE_ENTRY); 121 } 122 123 public void setFileEntry(FileEntry[] value) { 125 this.setValue(FILE_ENTRY, value); 126 } 127 128 public FileEntry[] getFileEntry() { 130 return (FileEntry[])this.getValues(FILE_ENTRY); 131 } 132 133 public int addFileEntry(org.netbeans.modules.j2ee.sun.share.plan.FileEntry value) throws java.beans.PropertyVetoException { 135 int positionOfNewItem = this.addValue(FILE_ENTRY, value); 136 return positionOfNewItem; 137 } 138 139 public int removeFileEntry(org.netbeans.modules.j2ee.sun.share.plan.FileEntry value) throws java.beans.PropertyVetoException { 144 return this.removeValue(FILE_ENTRY, value); 145 } 146 147 151 public FileEntry newFileEntry() { 152 return new FileEntry(); 153 } 154 155 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 157 comparators.add(c); 158 } 159 160 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 162 comparators.remove(c); 163 } 164 public void addVetoableChangeListener(String n, java.beans.VetoableChangeListener l) { 166 BeanProp p = this.beanProp(n); 167 if (p != null) 168 p.addVCListener(l); 169 } 170 171 public void removeVetoableChangeListener(String n, java.beans.VetoableChangeListener l) { 173 BeanProp p = this.beanProp(n); 174 if (p != null) 175 p.removeVCListener(l); 176 } 177 178 public static DeploymentPlan createGraph(org.w3c.dom.Node doc) throws org.netbeans.modules.schema2beans.Schema2BeansException { 183 return new DeploymentPlan(doc, Common.NO_DEFAULT_VALUES); 184 } 185 186 public static DeploymentPlan createGraph(java.io.InputStream in) throws org.netbeans.modules.schema2beans.Schema2BeansException { 187 return createGraph(in, false); 188 } 189 190 public static DeploymentPlan createGraph(java.io.InputStream in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException { 191 Document doc = GraphManager.createXmlDocument(in, validate); 192 return createGraph(doc); 193 } 194 195 public static DeploymentPlan createGraph() { 199 try { 200 return new DeploymentPlan(); 201 } 202 catch (Schema2BeansException e) { 203 throw new RuntimeException (e); 204 } 205 } 206 207 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 208 } 209 210 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { 212 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 213 write(baos); 214 String str = baos.toString();; 215 out.writeUTF(str); 217 } 218 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException , ClassNotFoundException { 220 try{ 221 init(comparators, runtimeVersion); 222 String strDocument = in.readUTF(); 223 ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes()); 225 Document doc = GraphManager.createXmlDocument(bais, false); 226 initOptions(Common.NO_DEFAULT_VALUES); 227 initFromNode(doc, Common.NO_DEFAULT_VALUES); 228 } 229 catch (Schema2BeansException e) { 230 throw new RuntimeException (e); 231 } 232 } 233 234 public void _setSchemaLocation(String location) { 235 if (beanProp().getAttrProp("xsi:schemaLocation", true) == null) { 236 createAttribute("xmlns:xsi", "xmlns:xsi", AttrProp.CDATA | AttrProp.IMPLIED, null, "http://www.w3.org/2001/XMLSchema-instance"); 237 setAttributeValue("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); 238 createAttribute("xsi:schemaLocation", "xsi:schemaLocation", AttrProp.CDATA | AttrProp.IMPLIED, null, location); 239 } 240 setAttributeValue("xsi:schemaLocation", location); 241 } 242 243 public String _getSchemaLocation() { 244 if (beanProp().getAttrProp("xsi:schemaLocation", true) == null) { 245 createAttribute("xmlns:xsi", "xmlns:xsi", AttrProp.CDATA | AttrProp.IMPLIED, null, "http://www.w3.org/2001/XMLSchema-instance"); 246 setAttributeValue("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); 247 createAttribute("xsi:schemaLocation", "xsi:schemaLocation", AttrProp.CDATA | AttrProp.IMPLIED, null, null); 248 } 249 return getAttributeValue("xsi:schemaLocation"); 250 } 251 252 public void dump(StringBuffer str, String indent){ 254 String s; 255 Object o; 256 org.netbeans.modules.schema2beans.BaseBean n; 257 str.append(indent); 258 str.append("FileEntry["+this.sizeFileEntry()+"]"); for(int i=0; i<this.sizeFileEntry(); i++) 260 { 261 str.append(indent+"\t"); 262 str.append("#"+i+":"); 263 n = (org.netbeans.modules.schema2beans.BaseBean) this.getFileEntry(i); 264 if (n != null) 265 n.dump(str, indent + "\t"); else 267 str.append(indent+"\tnull"); this.dumpAttributes(FILE_ENTRY, i, str, indent); 269 } 270 271 } 272 public String dumpBeanNode(){ 273 StringBuffer str = new StringBuffer (); 274 str.append("DeploymentPlan\n"); this.dump(str, "\n "); return str.toString(); 277 }} 278 279 281 282 304 305 | Popular Tags |