1 104 105 package com.sun.enterprise.tools.common.dd.webservice; 106 107 import org.w3c.dom.*; 108 import org.netbeans.modules.schema2beans.*; 109 import java.beans.*; 110 import java.util.*; 111 import java.io.*; 112 113 115 public class Webservices extends org.netbeans.modules.schema2beans.BaseBean 116 { 117 118 static Vector comparators = new Vector(); 119 120 static public final String DESCRIPTION = "Description"; static public final String DISPLAY_NAME = "DisplayName"; static public final String ICON = "Icon"; static public final String WEBSERVICE_DESCRIPTION = "WebserviceDescription"; 125 public Webservices() { 126 this(null, Common.USE_DEFAULT_VALUES); 127 } 128 129 public Webservices(org.w3c.dom.Node doc, int options) { 130 this(Common.NO_DEFAULT_VALUES); 131 try { 132 initFromNode(doc, options); 133 } 134 catch (Schema2BeansException e) { 135 e.printStackTrace(); 136 throw new RuntimeException (e.getMessage()); 137 } 138 } 139 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException 140 { 141 if (doc == null) 142 { 143 doc = GraphManager.createRootElementNode("webservices"); if (doc == null) 145 throw new Schema2BeansException("Cannot create DOM root"); } 147 Node n = GraphManager.getElementNode("webservices", doc); if (n == null) 149 throw new Schema2BeansException("Doc root not in the DOM graph"); ; 151 152 this.graphManager.setXmlDocument(doc); 153 154 this.createBean(n, this.graphManager()); 156 this.initialize(options); 157 } 158 public Webservices(int options) 159 { 160 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 161 initOptions(options); 162 } 163 protected void initOptions(int options) 164 { 165 this.graphManager = new GraphManager(this); 167 this.createRoot("webservices", "Webservices", Common.TYPE_1 | Common.TYPE_BEAN, Webservices.class); 169 170 this.createProperty("description", DESCRIPTION, 173 Common.TYPE_0_N | Common.TYPE_STRING | Common.TYPE_KEY, 174 java.lang.String .class); 175 this.createAttribute(DESCRIPTION, "id", "Id", 176 AttrProp.CDATA | AttrProp.IMPLIED, 177 null, null); 178 this.createAttribute(DESCRIPTION, "xml:lang", "XmlLang", 179 AttrProp.CDATA | AttrProp.IMPLIED, 180 null, null); 181 this.createProperty("display-name", DISPLAY_NAME, 183 Common.TYPE_0_N | Common.TYPE_STRING | Common.TYPE_KEY, 184 java.lang.String .class); 185 this.createAttribute(DISPLAY_NAME, "id", "Id", 186 AttrProp.CDATA | AttrProp.IMPLIED, 187 null, null); 188 this.createAttribute(DISPLAY_NAME, "xml:lang", "XmlLang", 189 AttrProp.CDATA | AttrProp.IMPLIED, 190 null, null); 191 this.createProperty("icon", ICON, 193 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 194 IconType.class); 195 this.createAttribute(ICON, "xml:lang", "XmlLang", 196 AttrProp.CDATA | AttrProp.IMPLIED, 197 null, null); 198 this.createAttribute(ICON, "id", "Id", 199 AttrProp.CDATA | AttrProp.IMPLIED, 200 null, null); 201 this.createProperty("webservice-description", WEBSERVICE_DESCRIPTION, 203 Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY, 204 WebserviceDescriptionType.class); 205 this.createAttribute(WEBSERVICE_DESCRIPTION, "id", "Id", 206 AttrProp.CDATA | AttrProp.IMPLIED, 207 null, null); 208 this.createAttribute("version", "Version", 209 AttrProp.CDATA | AttrProp.FIXED, 210 null, "1.1"); 211 this.createAttribute("id", "Id", 212 AttrProp.CDATA | AttrProp.IMPLIED, 213 null, null); 214 this.initialize(options); 215 } 216 217 void initialize(int options) 219 { 220 setDefaultNamespace("http://java.sun.com/xml/ns/j2ee"); 221 222 } 223 224 public void setDescription(int index, java.lang.String value) { 226 this.setValue(DESCRIPTION, index, value); 227 } 228 229 public java.lang.String getDescription(int index) { 231 return (java.lang.String )this.getValue(DESCRIPTION, index); 232 } 233 234 public void setDescription(java.lang.String [] value) { 236 this.setValue(DESCRIPTION, value); 237 } 238 239 public java.lang.String [] getDescription() { 241 return (java.lang.String [])this.getValues(DESCRIPTION); 242 } 243 244 public int sizeDescription() { 246 return this.size(DESCRIPTION); 247 } 248 249 public int addDescription(java.lang.String value) { 251 return this.addValue(DESCRIPTION, value); 252 } 253 254 public int removeDescription(java.lang.String value) { 259 return this.removeValue(DESCRIPTION, value); 260 } 261 262 public void setDisplayName(int index, java.lang.String value) { 264 this.setValue(DISPLAY_NAME, index, value); 265 } 266 267 public java.lang.String getDisplayName(int index) { 269 return (java.lang.String )this.getValue(DISPLAY_NAME, index); 270 } 271 272 public void setDisplayName(java.lang.String [] value) { 274 this.setValue(DISPLAY_NAME, value); 275 } 276 277 public java.lang.String [] getDisplayName() { 279 return (java.lang.String [])this.getValues(DISPLAY_NAME); 280 } 281 282 public int sizeDisplayName() { 284 return this.size(DISPLAY_NAME); 285 } 286 287 public int addDisplayName(java.lang.String value) { 289 return this.addValue(DISPLAY_NAME, value); 290 } 291 292 public int removeDisplayName(java.lang.String value) { 297 return this.removeValue(DISPLAY_NAME, value); 298 } 299 300 public void setIcon(int index, IconType value) { 302 this.setValue(ICON, index, value); 303 } 304 305 public IconType getIcon(int index) { 307 return (IconType)this.getValue(ICON, index); 308 } 309 310 public void setIcon(IconType[] value) { 312 this.setValue(ICON, value); 313 } 314 315 public IconType[] getIcon() { 317 return (IconType[])this.getValues(ICON); 318 } 319 320 public int sizeIcon() { 322 return this.size(ICON); 323 } 324 325 public int addIcon(com.sun.enterprise.tools.common.dd.webservice.IconType value) { 327 return this.addValue(ICON, value); 328 } 329 330 public int removeIcon(com.sun.enterprise.tools.common.dd.webservice.IconType value) { 335 return this.removeValue(ICON, value); 336 } 337 338 public void setWebserviceDescription(int index, WebserviceDescriptionType value) { 340 this.setValue(WEBSERVICE_DESCRIPTION, index, value); 341 } 342 343 public WebserviceDescriptionType getWebserviceDescription(int index) { 345 return (WebserviceDescriptionType)this.getValue(WEBSERVICE_DESCRIPTION, index); 346 } 347 348 public void setWebserviceDescription(WebserviceDescriptionType[] value) { 350 this.setValue(WEBSERVICE_DESCRIPTION, value); 351 } 352 353 public WebserviceDescriptionType[] getWebserviceDescription() { 355 return (WebserviceDescriptionType[])this.getValues(WEBSERVICE_DESCRIPTION); 356 } 357 358 public int sizeWebserviceDescription() { 360 return this.size(WEBSERVICE_DESCRIPTION); 361 } 362 363 public int addWebserviceDescription(com.sun.enterprise.tools.common.dd.webservice.WebserviceDescriptionType value) { 365 return this.addValue(WEBSERVICE_DESCRIPTION, value); 366 } 367 368 public int removeWebserviceDescription(com.sun.enterprise.tools.common.dd.webservice.WebserviceDescriptionType value) { 373 return this.removeValue(WEBSERVICE_DESCRIPTION, value); 374 } 375 376 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 378 comparators.add(c); 379 } 380 381 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 383 comparators.remove(c); 384 } 385 public static Webservices createGraph(org.w3c.dom.Node doc) { 390 return new Webservices(doc, Common.NO_DEFAULT_VALUES); 391 } 392 393 public static Webservices createGraph(java.io.InputStream in) { 394 return createGraph(in, false); 395 } 396 397 public static Webservices createGraph(java.io.InputStream in, boolean validate) { 398 try { 399 Document doc = GraphManager.createXmlDocument(in, validate); 400 return createGraph(doc); 401 } 402 catch (Exception t) { 403 t.printStackTrace(); 404 throw new RuntimeException ("DOM graph creation failed"); } 406 } 407 408 public static Webservices createGraph() { 412 return new Webservices(); 413 } 414 415 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 416 } 417 418 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { 420 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 421 write(baos); 422 String str = baos.toString();; 423 out.writeUTF(str); 425 } 426 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException , ClassNotFoundException { 428 try{ 429 init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 430 String strDocument = in.readUTF(); 431 ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes()); 433 Document doc = GraphManager.createXmlDocument(bais, false); 434 initOptions(Common.NO_DEFAULT_VALUES); 435 initFromNode(doc, Common.NO_DEFAULT_VALUES); 436 } 437 catch (Schema2BeansException e) { 438 e.printStackTrace(); 439 throw new RuntimeException (e.getMessage()); 440 } 441 } 442 443 public void dump(StringBuffer str, String indent){ 445 String s; 446 Object o; 447 org.netbeans.modules.schema2beans.BaseBean n; 448 str.append(indent); 449 str.append("Description["+this.sizeDescription()+"]"); for(int i=0; i<this.sizeDescription(); i++) 451 { 452 str.append(indent+"\t"); 453 str.append("#"+i+":"); 454 str.append(indent+"\t"); str.append("<"); s = this.getDescription(i); 457 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(DESCRIPTION, i, str, indent); 460 } 461 462 str.append(indent); 463 str.append("DisplayName["+this.sizeDisplayName()+"]"); for(int i=0; i<this.sizeDisplayName(); i++) 465 { 466 str.append(indent+"\t"); 467 str.append("#"+i+":"); 468 str.append(indent+"\t"); str.append("<"); s = this.getDisplayName(i); 471 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(DISPLAY_NAME, i, str, indent); 474 } 475 476 str.append(indent); 477 str.append("Icon["+this.sizeIcon()+"]"); for(int i=0; i<this.sizeIcon(); i++) 479 { 480 str.append(indent+"\t"); 481 str.append("#"+i+":"); 482 n = (org.netbeans.modules.schema2beans.BaseBean) this.getIcon(i); 483 if (n != null) 484 n.dump(str, indent + "\t"); else 486 str.append(indent+"\tnull"); this.dumpAttributes(ICON, i, str, indent); 488 } 489 490 str.append(indent); 491 str.append("WebserviceDescription["+this.sizeWebserviceDescription()+"]"); for(int i=0; i<this.sizeWebserviceDescription(); i++) 493 { 494 str.append(indent+"\t"); 495 str.append("#"+i+":"); 496 n = (org.netbeans.modules.schema2beans.BaseBean) this.getWebserviceDescription(i); 497 if (n != null) 498 n.dump(str, indent + "\t"); else 500 str.append(indent+"\tnull"); this.dumpAttributes(WEBSERVICE_DESCRIPTION, i, str, indent); 502 } 503 504 } 505 public String dumpBeanNode(){ 506 StringBuffer str = new StringBuffer (); 507 str.append("Webservices\n"); this.dump(str, "\n "); return str.toString(); 510 }} 511 512 514 515 537 | Popular Tags |