1 23 24 83 84 package com.sun.enterprise.tools.common.dd.webapp.data; 85 86 import org.w3c.dom.*; 87 import org.netbeans.modules.schema2beans.*; 88 import java.beans.*; 89 import java.util.*; 90 import java.io.*; 91 92 94 public class SunWebAppData extends com.sun.enterprise.tools.common.dd.SunBaseBean 95 { 96 97 static Vector comparators = new Vector(); 98 99 static public final String SESSION_PARAM = "SessionParam"; static public final String COOKIE_PARAM = "CookieParam"; static public final String JSP_PARAM = "JspParam"; static public final String EXTRA_PARAM = "ExtraParam"; static public final String MANAGER_PARAM = "ManagerParam"; static public final String STORE_PARAM = "StoreParam"; static public final String PERSISTENCE_PARAM = "PersistenceParam"; static public final String HELPER_CLASS_PARAM = "HelperClassParam"; 108 public SunWebAppData() throws org.netbeans.modules.schema2beans.Schema2BeansException { 109 this(null, Common.USE_DEFAULT_VALUES); 110 } 111 112 public SunWebAppData(org.w3c.dom.Node doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException { 113 this(Common.NO_DEFAULT_VALUES); 114 initFromNode(doc, options); 115 } 116 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException 117 { 118 if (doc == null) 119 { 120 doc = GraphManager.createRootElementNode("sun-web-app-data"); if (doc == null) 122 throw new Schema2BeansException(Common.getMessage( 123 "CantCreateDOMRoot_msg", "sun-web-app-data")); 124 } 125 Node n = GraphManager.getElementNode("sun-web-app-data", doc); if (n == null) 127 throw new Schema2BeansException(Common.getMessage( 128 "DocRootNotInDOMGraph_msg", "sun-web-app-data", doc.getFirstChild().getNodeName())); 129 130 this.graphManager.setXmlDocument(doc); 131 132 this.createBean(n, this.graphManager()); 134 this.initialize(options); 135 } 136 public SunWebAppData(int options) 137 { 138 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 139 initOptions(options); 140 } 141 protected void initOptions(int options) 142 { 143 this.graphManager = new GraphManager(this); 145 this.createRoot("sun-web-app-data", "SunWebAppData", Common.TYPE_1 | Common.TYPE_BEAN, SunWebAppData.class); 147 148 this.createProperty("session-param", SESSION_PARAM, 151 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 152 SessionParam.class); 153 this.createProperty("cookie-param", COOKIE_PARAM, 155 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 156 CookieParam.class); 157 this.createProperty("jsp-param", JSP_PARAM, 159 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 160 JspParam.class); 161 this.createProperty("extra-param", EXTRA_PARAM, 163 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 164 ExtraParam.class); 165 this.createProperty("manager-param", MANAGER_PARAM, 167 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 168 ManagerParam.class); 169 this.createProperty("store-param", STORE_PARAM, 171 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 172 StoreParam.class); 173 this.createProperty("persistence-param", PERSISTENCE_PARAM, 175 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 176 PersistenceParam.class); 177 this.createProperty("helper-class-param", HELPER_CLASS_PARAM, 179 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 180 HelperClassParam.class); 181 this.initialize(options); 182 } 183 184 void initialize(int options) 186 { 187 188 } 189 190 public void setSessionParam(int index, SessionParam value) { 192 this.setValue(SESSION_PARAM, index, value); 193 } 194 195 public SessionParam getSessionParam(int index) { 197 return (SessionParam)this.getValue(SESSION_PARAM, index); 198 } 199 200 public void setSessionParam(SessionParam[] value) { 202 this.setValue(SESSION_PARAM, value); 203 } 204 205 public SessionParam[] getSessionParam() { 207 return (SessionParam[])this.getValues(SESSION_PARAM); 208 } 209 210 public int sizeSessionParam() { 212 return this.size(SESSION_PARAM); 213 } 214 215 public int addSessionParam(com.sun.enterprise.tools.common.dd.webapp.data.SessionParam value) { 217 return this.addValue(SESSION_PARAM, value); 218 } 219 220 public int removeSessionParam(com.sun.enterprise.tools.common.dd.webapp.data.SessionParam value) { 225 return this.removeValue(SESSION_PARAM, value); 226 } 227 228 public void setCookieParam(int index, CookieParam value) { 230 this.setValue(COOKIE_PARAM, index, value); 231 } 232 233 public CookieParam getCookieParam(int index) { 235 return (CookieParam)this.getValue(COOKIE_PARAM, index); 236 } 237 238 public void setCookieParam(CookieParam[] value) { 240 this.setValue(COOKIE_PARAM, value); 241 } 242 243 public CookieParam[] getCookieParam() { 245 return (CookieParam[])this.getValues(COOKIE_PARAM); 246 } 247 248 public int sizeCookieParam() { 250 return this.size(COOKIE_PARAM); 251 } 252 253 public int addCookieParam(com.sun.enterprise.tools.common.dd.webapp.data.CookieParam value) { 255 return this.addValue(COOKIE_PARAM, value); 256 } 257 258 public int removeCookieParam(com.sun.enterprise.tools.common.dd.webapp.data.CookieParam value) { 263 return this.removeValue(COOKIE_PARAM, value); 264 } 265 266 public void setJspParam(int index, JspParam value) { 268 this.setValue(JSP_PARAM, index, value); 269 } 270 271 public JspParam getJspParam(int index) { 273 return (JspParam)this.getValue(JSP_PARAM, index); 274 } 275 276 public void setJspParam(JspParam[] value) { 278 this.setValue(JSP_PARAM, value); 279 } 280 281 public JspParam[] getJspParam() { 283 return (JspParam[])this.getValues(JSP_PARAM); 284 } 285 286 public int sizeJspParam() { 288 return this.size(JSP_PARAM); 289 } 290 291 public int addJspParam(com.sun.enterprise.tools.common.dd.webapp.data.JspParam value) { 293 return this.addValue(JSP_PARAM, value); 294 } 295 296 public int removeJspParam(com.sun.enterprise.tools.common.dd.webapp.data.JspParam value) { 301 return this.removeValue(JSP_PARAM, value); 302 } 303 304 public void setExtraParam(int index, ExtraParam value) { 306 this.setValue(EXTRA_PARAM, index, value); 307 } 308 309 public ExtraParam getExtraParam(int index) { 311 return (ExtraParam)this.getValue(EXTRA_PARAM, index); 312 } 313 314 public void setExtraParam(ExtraParam[] value) { 316 this.setValue(EXTRA_PARAM, value); 317 } 318 319 public ExtraParam[] getExtraParam() { 321 return (ExtraParam[])this.getValues(EXTRA_PARAM); 322 } 323 324 public int sizeExtraParam() { 326 return this.size(EXTRA_PARAM); 327 } 328 329 public int addExtraParam(com.sun.enterprise.tools.common.dd.webapp.data.ExtraParam value) { 331 return this.addValue(EXTRA_PARAM, value); 332 } 333 334 public int removeExtraParam(com.sun.enterprise.tools.common.dd.webapp.data.ExtraParam value) { 339 return this.removeValue(EXTRA_PARAM, value); 340 } 341 342 public void setManagerParam(int index, ManagerParam value) { 344 this.setValue(MANAGER_PARAM, index, value); 345 } 346 347 public ManagerParam getManagerParam(int index) { 349 return (ManagerParam)this.getValue(MANAGER_PARAM, index); 350 } 351 352 public void setManagerParam(ManagerParam[] value) { 354 this.setValue(MANAGER_PARAM, value); 355 } 356 357 public ManagerParam[] getManagerParam() { 359 return (ManagerParam[])this.getValues(MANAGER_PARAM); 360 } 361 362 public int sizeManagerParam() { 364 return this.size(MANAGER_PARAM); 365 } 366 367 public int addManagerParam(com.sun.enterprise.tools.common.dd.webapp.data.ManagerParam value) { 369 return this.addValue(MANAGER_PARAM, value); 370 } 371 372 public int removeManagerParam(com.sun.enterprise.tools.common.dd.webapp.data.ManagerParam value) { 377 return this.removeValue(MANAGER_PARAM, value); 378 } 379 380 public void setStoreParam(int index, StoreParam value) { 382 this.setValue(STORE_PARAM, index, value); 383 } 384 385 public StoreParam getStoreParam(int index) { 387 return (StoreParam)this.getValue(STORE_PARAM, index); 388 } 389 390 public void setStoreParam(StoreParam[] value) { 392 this.setValue(STORE_PARAM, value); 393 } 394 395 public StoreParam[] getStoreParam() { 397 return (StoreParam[])this.getValues(STORE_PARAM); 398 } 399 400 public int sizeStoreParam() { 402 return this.size(STORE_PARAM); 403 } 404 405 public int addStoreParam(com.sun.enterprise.tools.common.dd.webapp.data.StoreParam value) { 407 return this.addValue(STORE_PARAM, value); 408 } 409 410 public int removeStoreParam(com.sun.enterprise.tools.common.dd.webapp.data.StoreParam value) { 415 return this.removeValue(STORE_PARAM, value); 416 } 417 418 public void setPersistenceParam(int index, PersistenceParam value) { 420 this.setValue(PERSISTENCE_PARAM, index, value); 421 } 422 423 public PersistenceParam getPersistenceParam(int index) { 425 return (PersistenceParam)this.getValue(PERSISTENCE_PARAM, index); 426 } 427 428 public void setPersistenceParam(PersistenceParam[] value) { 430 this.setValue(PERSISTENCE_PARAM, value); 431 } 432 433 public PersistenceParam[] getPersistenceParam() { 435 return (PersistenceParam[])this.getValues(PERSISTENCE_PARAM); 436 } 437 438 public int sizePersistenceParam() { 440 return this.size(PERSISTENCE_PARAM); 441 } 442 443 public int addPersistenceParam(com.sun.enterprise.tools.common.dd.webapp.data.PersistenceParam value) { 445 return this.addValue(PERSISTENCE_PARAM, value); 446 } 447 448 public int removePersistenceParam(com.sun.enterprise.tools.common.dd.webapp.data.PersistenceParam value) { 453 return this.removeValue(PERSISTENCE_PARAM, value); 454 } 455 456 public void setHelperClassParam(int index, HelperClassParam value) { 458 this.setValue(HELPER_CLASS_PARAM, index, value); 459 } 460 461 public HelperClassParam getHelperClassParam(int index) { 463 return (HelperClassParam)this.getValue(HELPER_CLASS_PARAM, index); 464 } 465 466 public void setHelperClassParam(HelperClassParam[] value) { 468 this.setValue(HELPER_CLASS_PARAM, value); 469 } 470 471 public HelperClassParam[] getHelperClassParam() { 473 return (HelperClassParam[])this.getValues(HELPER_CLASS_PARAM); 474 } 475 476 public int sizeHelperClassParam() { 478 return this.size(HELPER_CLASS_PARAM); 479 } 480 481 public int addHelperClassParam(com.sun.enterprise.tools.common.dd.webapp.data.HelperClassParam value) { 483 return this.addValue(HELPER_CLASS_PARAM, value); 484 } 485 486 public int removeHelperClassParam(com.sun.enterprise.tools.common.dd.webapp.data.HelperClassParam value) { 491 return this.removeValue(HELPER_CLASS_PARAM, value); 492 } 493 494 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 496 comparators.add(c); 497 } 498 499 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 501 comparators.remove(c); 502 } 503 public static SunWebAppData createGraph(org.w3c.dom.Node doc) throws org.netbeans.modules.schema2beans.Schema2BeansException { 508 return new SunWebAppData(doc, Common.NO_DEFAULT_VALUES); 509 } 510 511 public static SunWebAppData createGraph(java.io.InputStream in) throws org.netbeans.modules.schema2beans.Schema2BeansException { 512 return createGraph(in, false); 513 } 514 515 public static SunWebAppData createGraph(java.io.InputStream in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException { 516 Document doc = GraphManager.createXmlDocument(in, validate); 517 return createGraph(doc); 518 } 519 520 public static SunWebAppData createGraph() { 524 try { 525 return new SunWebAppData(); 526 } 527 catch (Schema2BeansException e) { 528 throw new RuntimeException (e.getMessage()); 529 } 530 } 531 532 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 533 boolean restrictionFailure = false; 534 for (int _index = 0; _index < sizeSessionParam(); ++_index) { 536 com.sun.enterprise.tools.common.dd.webapp.data.SessionParam element = getSessionParam(_index); 537 if (element != null) { 538 element.validate(); 539 } 540 } 541 for (int _index = 0; _index < sizeCookieParam(); ++_index) { 543 com.sun.enterprise.tools.common.dd.webapp.data.CookieParam element = getCookieParam(_index); 544 if (element != null) { 545 element.validate(); 546 } 547 } 548 for (int _index = 0; _index < sizeJspParam(); ++_index) { 550 com.sun.enterprise.tools.common.dd.webapp.data.JspParam element = getJspParam(_index); 551 if (element != null) { 552 element.validate(); 553 } 554 } 555 for (int _index = 0; _index < sizeExtraParam(); ++_index) { 557 com.sun.enterprise.tools.common.dd.webapp.data.ExtraParam element = getExtraParam(_index); 558 if (element != null) { 559 element.validate(); 560 } 561 } 562 for (int _index = 0; _index < sizeManagerParam(); ++_index) { 564 com.sun.enterprise.tools.common.dd.webapp.data.ManagerParam element = getManagerParam(_index); 565 if (element != null) { 566 element.validate(); 567 } 568 } 569 for (int _index = 0; _index < sizeStoreParam(); ++_index) { 571 com.sun.enterprise.tools.common.dd.webapp.data.StoreParam element = getStoreParam(_index); 572 if (element != null) { 573 element.validate(); 574 } 575 } 576 for (int _index = 0; _index < sizePersistenceParam(); ++_index) { 578 com.sun.enterprise.tools.common.dd.webapp.data.PersistenceParam element = getPersistenceParam(_index); 579 if (element != null) { 580 element.validate(); 581 } 582 } 583 for (int _index = 0; _index < sizeHelperClassParam(); ++_index) { 585 com.sun.enterprise.tools.common.dd.webapp.data.HelperClassParam element = getHelperClassParam(_index); 586 if (element != null) { 587 element.validate(); 588 } 589 } 590 } 591 592 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { 594 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 595 write(baos); 596 String str = baos.toString();; 597 out.writeUTF(str); 599 } 600 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException , ClassNotFoundException { 602 try{ 603 init(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 604 String strDocument = in.readUTF(); 605 ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes()); 607 Document doc = GraphManager.createXmlDocument(bais, false); 608 initOptions(Common.NO_DEFAULT_VALUES); 609 initFromNode(doc, Common.NO_DEFAULT_VALUES); 610 } 611 catch (Schema2BeansException e) { 612 e.printStackTrace(); 613 throw new RuntimeException (e.getMessage()); 614 } 615 } 616 617 public void dump(StringBuffer str, String indent){ 619 String s; 620 Object o; 621 org.netbeans.modules.schema2beans.BaseBean n; 622 str.append(indent); 623 str.append("SessionParam["+this.sizeSessionParam()+"]"); for(int i=0; i<this.sizeSessionParam(); i++) 625 { 626 str.append(indent+"\t"); 627 str.append("#"+i+":"); 628 n = (org.netbeans.modules.schema2beans.BaseBean) this.getSessionParam(i); 629 if (n != null) 630 n.dump(str, indent + "\t"); else 632 str.append(indent+"\tnull"); this.dumpAttributes(SESSION_PARAM, i, str, indent); 634 } 635 636 str.append(indent); 637 str.append("CookieParam["+this.sizeCookieParam()+"]"); for(int i=0; i<this.sizeCookieParam(); i++) 639 { 640 str.append(indent+"\t"); 641 str.append("#"+i+":"); 642 n = (org.netbeans.modules.schema2beans.BaseBean) this.getCookieParam(i); 643 if (n != null) 644 n.dump(str, indent + "\t"); else 646 str.append(indent+"\tnull"); this.dumpAttributes(COOKIE_PARAM, i, str, indent); 648 } 649 650 str.append(indent); 651 str.append("JspParam["+this.sizeJspParam()+"]"); for(int i=0; i<this.sizeJspParam(); i++) 653 { 654 str.append(indent+"\t"); 655 str.append("#"+i+":"); 656 n = (org.netbeans.modules.schema2beans.BaseBean) this.getJspParam(i); 657 if (n != null) 658 n.dump(str, indent + "\t"); else 660 str.append(indent+"\tnull"); this.dumpAttributes(JSP_PARAM, i, str, indent); 662 } 663 664 str.append(indent); 665 str.append("ExtraParam["+this.sizeExtraParam()+"]"); for(int i=0; i<this.sizeExtraParam(); i++) 667 { 668 str.append(indent+"\t"); 669 str.append("#"+i+":"); 670 n = (org.netbeans.modules.schema2beans.BaseBean) this.getExtraParam(i); 671 if (n != null) 672 n.dump(str, indent + "\t"); else 674 str.append(indent+"\tnull"); this.dumpAttributes(EXTRA_PARAM, i, str, indent); 676 } 677 678 str.append(indent); 679 str.append("ManagerParam["+this.sizeManagerParam()+"]"); for(int i=0; i<this.sizeManagerParam(); i++) 681 { 682 str.append(indent+"\t"); 683 str.append("#"+i+":"); 684 n = (org.netbeans.modules.schema2beans.BaseBean) this.getManagerParam(i); 685 if (n != null) 686 n.dump(str, indent + "\t"); else 688 str.append(indent+"\tnull"); this.dumpAttributes(MANAGER_PARAM, i, str, indent); 690 } 691 692 str.append(indent); 693 str.append("StoreParam["+this.sizeStoreParam()+"]"); for(int i=0; i<this.sizeStoreParam(); i++) 695 { 696 str.append(indent+"\t"); 697 str.append("#"+i+":"); 698 n = (org.netbeans.modules.schema2beans.BaseBean) this.getStoreParam(i); 699 if (n != null) 700 n.dump(str, indent + "\t"); else 702 str.append(indent+"\tnull"); this.dumpAttributes(STORE_PARAM, i, str, indent); 704 } 705 706 str.append(indent); 707 str.append("PersistenceParam["+this.sizePersistenceParam()+"]"); for(int i=0; i<this.sizePersistenceParam(); i++) 709 { 710 str.append(indent+"\t"); 711 str.append("#"+i+":"); 712 n = (org.netbeans.modules.schema2beans.BaseBean) this.getPersistenceParam(i); 713 if (n != null) 714 n.dump(str, indent + "\t"); else 716 str.append(indent+"\tnull"); this.dumpAttributes(PERSISTENCE_PARAM, i, str, indent); 718 } 719 720 str.append(indent); 721 str.append("HelperClassParam["+this.sizeHelperClassParam()+"]"); for(int i=0; i<this.sizeHelperClassParam(); i++) 723 { 724 str.append(indent+"\t"); 725 str.append("#"+i+":"); 726 n = (org.netbeans.modules.schema2beans.BaseBean) this.getHelperClassParam(i); 727 if (n != null) 728 n.dump(str, indent + "\t"); else 730 str.append(indent+"\tnull"); this.dumpAttributes(HELPER_CLASS_PARAM, i, str, indent); 732 } 733 734 } 735 public String dumpBeanNode(){ 736 StringBuffer str = new StringBuffer (); 737 str.append("SunWebAppData\n"); this.dump(str, "\n "); return str.toString(); 740 }} 741 742 744 745 766 | Popular Tags |