1 18 package org.enhydra.convert.xml; 19 20 import java.io.File ; 22 import java.io.FileReader ; 23 import java.io.FileWriter ; 24 import java.io.InputStream ; 25 import java.io.InputStreamReader ; 26 import java.io.IOException ; 27 import java.io.OutputStream ; 28 import java.io.OutputStreamWriter ; 29 import java.io.Reader ; 30 import java.io.Writer ; 31 import java.util.HashMap ; 32 import java.util.Iterator ; 33 import java.util.Map ; 34 import org.xml.sax.EntityResolver ; 35 import org.xml.sax.ErrorHandler ; 36 import org.xml.sax.InputSource ; 37 import org.xml.sax.Locator ; 38 import org.xml.sax.SAXException ; 39 import org.xml.sax.SAXParseException ; 40 import org.xml.sax.XMLReader ; 41 import org.xml.sax.ext.LexicalHandler ; 42 import org.xml.sax.helpers.DefaultHandler ; 43 import org.xml.sax.helpers.XMLReaderFactory ; 44 45 import java.util.Iterator ; 47 import java.util.List ; 48 import java.util.LinkedList ; 49 50 public class WebAppImpl extends DefaultHandler implements Cloneable , Unmarshallable, LexicalHandler , WebApp { 51 52 private Icon icon; 53 private DisplayName displayName; 54 private Description description; 55 private Distributable distributable; 56 private List contextParamList; 57 private List filterList; 58 private List filterMappingList; 59 private List listenerList; 60 private List servletList; 61 private List servletMappingList; 62 private SessionConfig sessionConfig; 63 private List mimeMappingList; 64 private WelcomeFileList welcomeFileList; 65 private List errorPageList; 66 private List taglibList; 67 private List resourceEnvRefList; 68 private List resourceRefList; 69 private List securityConstraintList; 70 private LoginConfig loginConfig; 71 private List securityRoleList; 72 private List envEntryList; 73 private List ejbRefList; 74 private List ejbLocalRefList; 75 private String id; 76 private boolean zeus_IdSet; 77 78 79 private String docTypeString; 80 81 82 private String outputEncoding; 83 84 85 private Unmarshallable zeus_currentUNode; 86 87 88 private Unmarshallable zeus_parentUNode; 89 90 91 private boolean zeus_thisNodeHandled = false; 92 93 94 private boolean hasDTD; 95 96 97 private boolean validate; 98 99 100 private Map namespaceMappings; 101 102 103 private static EntityResolver entityResolver; 104 105 106 private static ErrorHandler errorHandler; 107 108 private static WebAppImpl prototype = null; 109 110 public static void setPrototype(WebAppImpl prototype) { 111 WebAppImpl.prototype = prototype; 112 } 113 public static WebAppImpl newInstance() { 114 try { 115 return (prototype!=null)?(WebAppImpl)prototype.clone(): new WebAppImpl(); 116 } catch (CloneNotSupportedException e) { 117 return null; } 119 } 120 public WebAppImpl() { 121 contextParamList = new LinkedList (); 122 filterList = new LinkedList (); 123 filterMappingList = new LinkedList (); 124 listenerList = new LinkedList (); 125 servletList = new LinkedList (); 126 servletMappingList = new LinkedList (); 127 mimeMappingList = new LinkedList (); 128 errorPageList = new LinkedList (); 129 taglibList = new LinkedList (); 130 resourceEnvRefList = new LinkedList (); 131 resourceRefList = new LinkedList (); 132 securityConstraintList = new LinkedList (); 133 securityRoleList = new LinkedList (); 134 envEntryList = new LinkedList (); 135 ejbRefList = new LinkedList (); 136 ejbLocalRefList = new LinkedList (); 137 zeus_IdSet = false; 138 docTypeString = ""; 139 hasDTD = false; 140 validate = false; 141 namespaceMappings = new HashMap (); 142 } 143 144 public Icon getIcon() { 145 return icon; 146 } 147 148 public void setIcon(Icon icon) { 149 this.icon = icon; 150 } 151 152 public DisplayName getDisplayName() { 153 return displayName; 154 } 155 156 public void setDisplayName(DisplayName displayName) { 157 this.displayName = displayName; 158 } 159 160 public Description getDescription() { 161 return description; 162 } 163 164 public void setDescription(Description description) { 165 this.description = description; 166 } 167 168 public Distributable getDistributable() { 169 return distributable; 170 } 171 172 public void setDistributable(Distributable distributable) { 173 this.distributable = distributable; 174 } 175 176 public List getContextParamList() { 177 return contextParamList; 178 } 179 180 public void setContextParamList(List contextParamList) { 181 this.contextParamList = contextParamList; 182 } 183 184 public void addContextParam(ContextParam contextParam) { 185 contextParamList.add(contextParam); 186 } 187 188 public void removeContextParam(ContextParam contextParam) { 189 contextParamList.remove(contextParam); 190 } 191 192 public List getFilterList() { 193 return filterList; 194 } 195 196 public void setFilterList(List filterList) { 197 this.filterList = filterList; 198 } 199 200 public void addFilter(Filter filter) { 201 filterList.add(filter); 202 } 203 204 public void removeFilter(Filter filter) { 205 filterList.remove(filter); 206 } 207 208 public List getFilterMappingList() { 209 return filterMappingList; 210 } 211 212 public void setFilterMappingList(List filterMappingList) { 213 this.filterMappingList = filterMappingList; 214 } 215 216 public void addFilterMapping(FilterMapping filterMapping) { 217 filterMappingList.add(filterMapping); 218 } 219 220 public void removeFilterMapping(FilterMapping filterMapping) { 221 filterMappingList.remove(filterMapping); 222 } 223 224 public List getListenerList() { 225 return listenerList; 226 } 227 228 public void setListenerList(List listenerList) { 229 this.listenerList = listenerList; 230 } 231 232 public void addListener(Listener listener) { 233 listenerList.add(listener); 234 } 235 236 public void removeListener(Listener listener) { 237 listenerList.remove(listener); 238 } 239 240 public List getServletList() { 241 return servletList; 242 } 243 244 public void setServletList(List servletList) { 245 this.servletList = servletList; 246 } 247 248 public void addServlet(Servlet servlet) { 249 servletList.add(servlet); 250 } 251 252 public void removeServlet(Servlet servlet) { 253 servletList.remove(servlet); 254 } 255 256 public List getServletMappingList() { 257 return servletMappingList; 258 } 259 260 public void setServletMappingList(List servletMappingList) { 261 this.servletMappingList = servletMappingList; 262 } 263 264 public void addServletMapping(ServletMapping servletMapping) { 265 servletMappingList.add(servletMapping); 266 } 267 268 public void removeServletMapping(ServletMapping servletMapping) { 269 servletMappingList.remove(servletMapping); 270 } 271 272 public SessionConfig getSessionConfig() { 273 return sessionConfig; 274 } 275 276 public void setSessionConfig(SessionConfig sessionConfig) { 277 this.sessionConfig = sessionConfig; 278 } 279 280 public List getMimeMappingList() { 281 return mimeMappingList; 282 } 283 284 public void setMimeMappingList(List mimeMappingList) { 285 this.mimeMappingList = mimeMappingList; 286 } 287 288 public void addMimeMapping(MimeMapping mimeMapping) { 289 mimeMappingList.add(mimeMapping); 290 } 291 292 public void removeMimeMapping(MimeMapping mimeMapping) { 293 mimeMappingList.remove(mimeMapping); 294 } 295 296 public WelcomeFileList getWelcomeFileList() { 297 return welcomeFileList; 298 } 299 300 public void setWelcomeFileList(WelcomeFileList welcomeFileList) { 301 this.welcomeFileList = welcomeFileList; 302 } 303 304 public List getErrorPageList() { 305 return errorPageList; 306 } 307 308 public void setErrorPageList(List errorPageList) { 309 this.errorPageList = errorPageList; 310 } 311 312 public void addErrorPage(ErrorPage errorPage) { 313 errorPageList.add(errorPage); 314 } 315 316 public void removeErrorPage(ErrorPage errorPage) { 317 errorPageList.remove(errorPage); 318 } 319 320 public List getTaglibList() { 321 return taglibList; 322 } 323 324 public void setTaglibList(List taglibList) { 325 this.taglibList = taglibList; 326 } 327 328 public void addTaglib(Taglib taglib) { 329 taglibList.add(taglib); 330 } 331 332 public void removeTaglib(Taglib taglib) { 333 taglibList.remove(taglib); 334 } 335 336 public List getResourceEnvRefList() { 337 return resourceEnvRefList; 338 } 339 340 public void setResourceEnvRefList(List resourceEnvRefList) { 341 this.resourceEnvRefList = resourceEnvRefList; 342 } 343 344 public void addResourceEnvRef(ResourceEnvRef resourceEnvRef) { 345 resourceEnvRefList.add(resourceEnvRef); 346 } 347 348 public void removeResourceEnvRef(ResourceEnvRef resourceEnvRef) { 349 resourceEnvRefList.remove(resourceEnvRef); 350 } 351 352 public List getResourceRefList() { 353 return resourceRefList; 354 } 355 356 public void setResourceRefList(List resourceRefList) { 357 this.resourceRefList = resourceRefList; 358 } 359 360 public void addResourceRef(ResourceRef resourceRef) { 361 resourceRefList.add(resourceRef); 362 } 363 364 public void removeResourceRef(ResourceRef resourceRef) { 365 resourceRefList.remove(resourceRef); 366 } 367 368 public List getSecurityConstraintList() { 369 return securityConstraintList; 370 } 371 372 public void setSecurityConstraintList(List securityConstraintList) { 373 this.securityConstraintList = securityConstraintList; 374 } 375 376 public void addSecurityConstraint(SecurityConstraint securityConstraint) { 377 securityConstraintList.add(securityConstraint); 378 } 379 380 public void removeSecurityConstraint(SecurityConstraint securityConstraint) { 381 securityConstraintList.remove(securityConstraint); 382 } 383 384 public LoginConfig getLoginConfig() { 385 return loginConfig; 386 } 387 388 public void setLoginConfig(LoginConfig loginConfig) { 389 this.loginConfig = loginConfig; 390 } 391 392 public List getSecurityRoleList() { 393 return securityRoleList; 394 } 395 396 public void setSecurityRoleList(List securityRoleList) { 397 this.securityRoleList = securityRoleList; 398 } 399 400 public void addSecurityRole(SecurityRole securityRole) { 401 securityRoleList.add(securityRole); 402 } 403 404 public void removeSecurityRole(SecurityRole securityRole) { 405 securityRoleList.remove(securityRole); 406 } 407 408 public List getEnvEntryList() { 409 return envEntryList; 410 } 411 412 public void setEnvEntryList(List envEntryList) { 413 this.envEntryList = envEntryList; 414 } 415 416 public void addEnvEntry(EnvEntry envEntry) { 417 envEntryList.add(envEntry); 418 } 419 420 public void removeEnvEntry(EnvEntry envEntry) { 421 envEntryList.remove(envEntry); 422 } 423 424 public List getEjbRefList() { 425 return ejbRefList; 426 } 427 428 public void setEjbRefList(List ejbRefList) { 429 this.ejbRefList = ejbRefList; 430 } 431 432 public void addEjbRef(EjbRef ejbRef) { 433 ejbRefList.add(ejbRef); 434 } 435 436 public void removeEjbRef(EjbRef ejbRef) { 437 ejbRefList.remove(ejbRef); 438 } 439 440 public List getEjbLocalRefList() { 441 return ejbLocalRefList; 442 } 443 444 public void setEjbLocalRefList(List ejbLocalRefList) { 445 this.ejbLocalRefList = ejbLocalRefList; 446 } 447 448 public void addEjbLocalRef(EjbLocalRef ejbLocalRef) { 449 ejbLocalRefList.add(ejbLocalRef); 450 } 451 452 public void removeEjbLocalRef(EjbLocalRef ejbLocalRef) { 453 ejbLocalRefList.remove(ejbLocalRef); 454 } 455 456 public String getId() { 457 return id; 458 } 459 460 public void setId(String id) { 461 this.id = id; 462 zeus_IdSet = true; 463 } 464 465 public void setDocType(String name, String publicID, String systemID) { 466 try { 467 startDTD(name, publicID, systemID); 468 } catch (SAXException neverHappens) { } 469 } 470 471 public void setOutputEncoding(String outputEncoding) { 472 this.outputEncoding = outputEncoding; 473 } 474 475 public void marshal(File file) throws IOException { 476 marshal(new FileWriter (file)); 478 } 479 480 public void marshal(OutputStream outputStream) throws IOException { 481 marshal(new OutputStreamWriter (outputStream)); 483 } 484 485 public void marshal(Writer writer) throws IOException { 486 writer.write("<?xml version=\"1.0\" "); 488 if (outputEncoding != null) { 489 writer.write("encoding=\""); 490 writer.write(outputEncoding); 491 writer.write("\"?>\n\n"); 492 493 } else { 494 writer.write("encoding=\"UTF-8\"?>\n\n"); 495 496 } 497 writer.write(docTypeString); 499 writer.write("\n"); 500 writeXMLRepresentation(writer, ""); 502 503 writer.flush(); 505 writer.close(); 506 } 507 508 protected void writeXMLRepresentation(Writer writer, 509 String indent) 510 throws IOException { 511 512 writer.write(indent); 513 writer.write("<web-app"); 514 515 for (Iterator i = namespaceMappings.keySet().iterator(); i.hasNext(); ) { 517 String prefix = (String )i.next(); 518 String uri = (String )namespaceMappings.get(prefix); 519 writer.write(" xmlns"); 520 if (!prefix.trim().equals("")) { 521 writer.write(":"); 522 writer.write(prefix); 523 } 524 writer.write("=\""); 525 writer.write(uri); 526 writer.write("\"\n "); 527 } 528 529 if (zeus_IdSet) { 531 writer.write(" id=\""); 532 writer.write(escapeAttributeValue(id)); 533 writer.write("\""); 534 } 535 writer.write(">"); 536 writer.write("\n"); 537 538 if (icon != null) { 540 ((IconImpl)icon).writeXMLRepresentation(writer, 541 new StringBuffer (indent).append(" ").toString()); 542 } 543 544 if (displayName != null) { 545 ((DisplayNameImpl)displayName).writeXMLRepresentation(writer, 546 new StringBuffer (indent).append(" ").toString()); 547 } 548 549 if (description != null) { 550 ((DescriptionImpl)description).writeXMLRepresentation(writer, 551 new StringBuffer (indent).append(" ").toString()); 552 } 553 554 if (distributable != null) { 555 ((DistributableImpl)distributable).writeXMLRepresentation(writer, 556 new StringBuffer (indent).append(" ").toString()); 557 } 558 559 for (Iterator i=contextParamList.iterator(); i.hasNext(); ) { 560 ContextParamImpl contextParam = (ContextParamImpl)i.next(); 561 contextParam.writeXMLRepresentation(writer, 562 new StringBuffer (indent).append(" ").toString()); 563 } 564 for (Iterator i=filterList.iterator(); i.hasNext(); ) { 565 FilterImpl filter = (FilterImpl)i.next(); 566 filter.writeXMLRepresentation(writer, 567 new StringBuffer (indent).append(" ").toString()); 568 } 569 for (Iterator i=filterMappingList.iterator(); i.hasNext(); ) { 570 FilterMappingImpl filterMapping = (FilterMappingImpl)i.next(); 571 filterMapping.writeXMLRepresentation(writer, 572 new StringBuffer (indent).append(" ").toString()); 573 } 574 for (Iterator i=listenerList.iterator(); i.hasNext(); ) { 575 ListenerImpl listener = (ListenerImpl)i.next(); 576 listener.writeXMLRepresentation(writer, 577 new StringBuffer (indent).append(" ").toString()); 578 } 579 for (Iterator i=servletList.iterator(); i.hasNext(); ) { 580 ServletImpl servlet = (ServletImpl)i.next(); 581 servlet.writeXMLRepresentation(writer, 582 new StringBuffer (indent).append(" ").toString()); 583 } 584 for (Iterator i=servletMappingList.iterator(); i.hasNext(); ) { 585 ServletMappingImpl servletMapping = (ServletMappingImpl)i.next(); 586 servletMapping.writeXMLRepresentation(writer, 587 new StringBuffer (indent).append(" ").toString()); 588 } 589 if (sessionConfig != null) { 590 ((SessionConfigImpl)sessionConfig).writeXMLRepresentation(writer, 591 new StringBuffer (indent).append(" ").toString()); 592 } 593 594 for (Iterator i=mimeMappingList.iterator(); i.hasNext(); ) { 595 MimeMappingImpl mimeMapping = (MimeMappingImpl)i.next(); 596 mimeMapping.writeXMLRepresentation(writer, 597 new StringBuffer (indent).append(" ").toString()); 598 } 599 if (welcomeFileList != null) { 600 ((WelcomeFileListImpl)welcomeFileList).writeXMLRepresentation(writer, 601 new StringBuffer (indent).append(" ").toString()); 602 } 603 604 for (Iterator i=errorPageList.iterator(); i.hasNext(); ) { 605 ErrorPageImpl errorPage = (ErrorPageImpl)i.next(); 606 errorPage.writeXMLRepresentation(writer, 607 new StringBuffer (indent).append(" ").toString()); 608 } 609 for (Iterator i=taglibList.iterator(); i.hasNext(); ) { 610 TaglibImpl taglib = (TaglibImpl)i.next(); 611 taglib.writeXMLRepresentation(writer, 612 new StringBuffer (indent).append(" ").toString()); 613 } 614 for (Iterator i=resourceEnvRefList.iterator(); i.hasNext(); ) { 615 ResourceEnvRefImpl resourceEnvRef = (ResourceEnvRefImpl)i.next(); 616 resourceEnvRef.writeXMLRepresentation(writer, 617 new StringBuffer (indent).append(" ").toString()); 618 } 619 for (Iterator i=resourceRefList.iterator(); i.hasNext(); ) { 620 ResourceRefImpl resourceRef = (ResourceRefImpl)i.next(); 621 resourceRef.writeXMLRepresentation(writer, 622 new StringBuffer (indent).append(" ").toString()); 623 } 624 for (Iterator i=securityConstraintList.iterator(); i.hasNext(); ) { 625 SecurityConstraintImpl securityConstraint = (SecurityConstraintImpl)i.next(); 626 securityConstraint.writeXMLRepresentation(writer, 627 new StringBuffer (indent).append(" ").toString()); 628 } 629 if (loginConfig != null) { 630 ((LoginConfigImpl)loginConfig).writeXMLRepresentation(writer, 631 new StringBuffer (indent).append(" ").toString()); 632 } 633 634 for (Iterator i=securityRoleList.iterator(); i.hasNext(); ) { 635 SecurityRoleImpl securityRole = (SecurityRoleImpl)i.next(); 636 securityRole.writeXMLRepresentation(writer, 637 new StringBuffer (indent).append(" ").toString()); 638 } 639 for (Iterator i=envEntryList.iterator(); i.hasNext(); ) { 640 EnvEntryImpl envEntry = (EnvEntryImpl)i.next(); 641 envEntry.writeXMLRepresentation(writer, 642 new StringBuffer (indent).append(" ").toString()); 643 } 644 for (Iterator i=ejbRefList.iterator(); i.hasNext(); ) { 645 EjbRefImpl ejbRef = (EjbRefImpl)i.next(); 646 ejbRef.writeXMLRepresentation(writer, 647 new StringBuffer (indent).append(" ").toString()); 648 } 649 for (Iterator i=ejbLocalRefList.iterator(); i.hasNext(); ) { 650 EjbLocalRefImpl ejbLocalRef = (EjbLocalRefImpl)i.next(); 651 ejbLocalRef.writeXMLRepresentation(writer, 652 new StringBuffer (indent).append(" ").toString()); 653 } 654 writer.write(indent); 655 writer.write("</web-app>\n"); 656 } 657 658 private String escapeAttributeValue(String attributeValue) { 659 String returnValue = attributeValue; 660 for (int i = 0; i < returnValue.length(); i++) { 661 char ch = returnValue.charAt(i); 662 if (ch == '"') { 663 returnValue = new StringBuffer () 664 .append(returnValue.substring(0, i)) 665 .append(""") 666 .append(returnValue.substring(i+1)) 667 .toString(); 668 } 669 } 670 return returnValue; 671 } 672 673 private String escapeTextValue(String textValue) { 674 String returnValue = textValue; 675 for (int i = 0; i < returnValue.length(); i++) { 676 char ch = returnValue.charAt(i); 677 if (ch == '<') { 678 returnValue = new StringBuffer () 679 .append(returnValue.substring(0, i)) 680 .append("<") 681 .append(returnValue.substring(i+1)) 682 .toString(); 683 } else if (ch == '>') { 684 returnValue = new StringBuffer () 685 .append(returnValue.substring(0, i)) 686 .append(">") 687 .append(returnValue.substring(i+1)) 688 .toString(); 689 } 690 } 691 return returnValue; 692 } 693 694 701 public static void setEntityResolver(EntityResolver resolver) { 702 entityResolver = resolver; 703 } 704 705 712 public static void setErrorHandler(ErrorHandler handler) { 713 errorHandler = handler; 714 } 715 716 public static WebApp unmarshal(File file) throws IOException { 717 return unmarshal(new FileReader (file)); 719 } 720 721 public static WebApp unmarshal(File file, boolean validate) throws IOException { 722 return unmarshal(new FileReader (file), validate); 724 } 725 726 public static WebApp unmarshal(InputStream inputStream) throws IOException { 727 return unmarshal(new InputStreamReader (inputStream)); 729 } 730 731 public static WebApp unmarshal(InputStream inputStream, boolean validate) throws IOException { 732 return unmarshal(new InputStreamReader (inputStream), validate); 734 } 735 736 public static WebApp unmarshal(Reader reader) throws IOException { 737 return unmarshal(reader, false); 739 } 740 741 public static WebApp unmarshal(Reader reader, boolean validate) throws IOException { 742 WebAppImpl webApp = WebAppImpl.newInstance(); 743 webApp.setValidating(validate); 744 webApp.setCurrentUNode(webApp); 745 webApp.setParentUNode(null); 746 XMLReader parser = null; 748 String parserClass = System.getProperty("org.xml.sax.driver", 749 "org.apache.xerces.parsers.SAXParser"); 750 try { 751 parser = XMLReaderFactory.createXMLReader(parserClass); 752 753 if (entityResolver != null) { 755 parser.setEntityResolver(entityResolver); 756 } 757 758 parser.setErrorHandler(webApp); 760 761 parser.setProperty("http://xml.org/sax/properties/lexical-handler", webApp); 763 764 parser.setContentHandler(webApp); 766 } catch (SAXException e) { 767 throw new IOException ("Could not load XML parser: " + 768 e.getMessage()); 769 } 770 771 InputSource inputSource = new InputSource (reader); 772 try { 773 parser.setFeature("http://xml.org/sax/features/validation", new Boolean (validate).booleanValue()); 774 parser.setFeature("http://xml.org/sax/features/namespaces", true); 775 parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false); 776 parser.parse(inputSource); 777 } catch (SAXException e) { 778 throw new IOException ("Error parsing XML document: " + 779 e.getMessage()); 780 } 781 782 return webApp; 784 } 785 786 public Unmarshallable getParentUNode() { 787 return zeus_parentUNode; 788 } 789 790 public void setParentUNode(Unmarshallable parentUNode) { 791 this.zeus_parentUNode = parentUNode; 792 } 793 794 public Unmarshallable getCurrentUNode() { 795 return zeus_currentUNode; 796 } 797 798 public void setCurrentUNode(Unmarshallable currentUNode) { 799 this.zeus_currentUNode = currentUNode; 800 } 801 802 public void setValidating(boolean validate) { 803 this.validate = validate; 804 } 805 806 public void startDocument() throws SAXException { 807 } 809 810 public void setDocumentLocator(Locator locator) { 811 } 813 814 public void startPrefixMapping(String prefix, String uri) 815 throws SAXException { 816 namespaceMappings.put(prefix, uri); 817 } 818 819 public void startElement(String namespaceURI, String localName, 820 String qName, org.xml.sax.Attributes atts) 821 throws SAXException { 822 823 Unmarshallable current = getCurrentUNode(); 825 if (current != this) { 826 current.startElement(namespaceURI, localName, qName, atts); 827 return; 828 } 829 830 if ((localName.equals("web-app")) && (!zeus_thisNodeHandled)) { 832 for (int i=0, len=atts.getLength(); i<len; i++) { 834 String attName= atts.getLocalName(i); 835 String attValue = atts.getValue(i); 836 if (attName.equals("id")) { 837 setId(attValue); 838 } 839 } 840 zeus_thisNodeHandled = true; 841 return; 842 } else { 843 if (localName.equals("icon") && (icon==null)) { 845 IconImpl icon = IconImpl.newInstance(); 846 current = getCurrentUNode(); 847 icon.setParentUNode(current); 848 icon.setCurrentUNode(icon); 849 this.setCurrentUNode(icon); 850 icon.startElement(namespaceURI, localName, qName, atts); 851 this.icon = icon; 853 return; 854 } 855 if (localName.equals("display-name") && (displayName==null)) { 856 DisplayNameImpl displayName = DisplayNameImpl.newInstance(); 857 current = getCurrentUNode(); 858 displayName.setParentUNode(current); 859 displayName.setCurrentUNode(displayName); 860 this.setCurrentUNode(displayName); 861 displayName.startElement(namespaceURI, localName, qName, atts); 862 this.displayName = displayName; 864 return; 865 } 866 if (localName.equals("description") && (description==null)) { 867 DescriptionImpl description = DescriptionImpl.newInstance(); 868 current = getCurrentUNode(); 869 description.setParentUNode(current); 870 description.setCurrentUNode(description); 871 this.setCurrentUNode(description); 872 description.startElement(namespaceURI, localName, qName, atts); 873 this.description = description; 875 return; 876 } 877 if (localName.equals("distributable") && (distributable==null)) { 878 DistributableImpl distributable = DistributableImpl.newInstance(); 879 current = getCurrentUNode(); 880 distributable.setParentUNode(current); 881 distributable.setCurrentUNode(distributable); 882 this.setCurrentUNode(distributable); 883 distributable.startElement(namespaceURI, localName, qName, atts); 884 this.distributable = distributable; 886 return; 887 } 888 if (localName.equals("context-param")) { 889 ContextParamImpl contextParam = ContextParamImpl.newInstance(); 890 current = getCurrentUNode(); 891 contextParam.setParentUNode(current); 892 contextParam.setCurrentUNode(contextParam); 893 this.setCurrentUNode(contextParam); 894 contextParam.startElement(namespaceURI, localName, qName, atts); 895 contextParamList.add(contextParam); 897 return; 898 } 899 if (localName.equals("filter")) { 900 FilterImpl filter = FilterImpl.newInstance(); 901 current = getCurrentUNode(); 902 filter.setParentUNode(current); 903 filter.setCurrentUNode(filter); 904 this.setCurrentUNode(filter); 905 filter.startElement(namespaceURI, localName, qName, atts); 906 filterList.add(filter); 908 return; 909 } 910 if (localName.equals("filter-mapping")) { 911 FilterMappingImpl filterMapping = FilterMappingImpl.newInstance(); 912 current = getCurrentUNode(); 913 filterMapping.setParentUNode(current); 914 filterMapping.setCurrentUNode(filterMapping); 915 this.setCurrentUNode(filterMapping); 916 filterMapping.startElement(namespaceURI, localName, qName, atts); 917 filterMappingList.add(filterMapping); 919 return; 920 } 921 if (localName.equals("listener")) { 922 ListenerImpl listener = ListenerImpl.newInstance(); 923 current = getCurrentUNode(); 924 listener.setParentUNode(current); 925 listener.setCurrentUNode(listener); 926 this.setCurrentUNode(listener); 927 listener.startElement(namespaceURI, localName, qName, atts); 928 listenerList.add(listener); 930 return; 931 } 932 if (localName.equals("servlet")) { 933 ServletImpl servlet = ServletImpl.newInstance(); 934 current = getCurrentUNode(); 935 servlet.setParentUNode(current); 936 servlet.setCurrentUNode(servlet); 937 this.setCurrentUNode(servlet); 938 servlet.startElement(namespaceURI, localName, qName, atts); 939 servletList.add(servlet); 941 return; 942 } 943 if (localName.equals("servlet-mapping")) { 944 ServletMappingImpl servletMapping = ServletMappingImpl.newInstance(); 945 current = getCurrentUNode(); 946 servletMapping.setParentUNode(current); 947 servletMapping.setCurrentUNode(servletMapping); 948 this.setCurrentUNode(servletMapping); 949 servletMapping.startElement(namespaceURI, localName, qName, atts); 950 servletMappingList.add(servletMapping); 952 return; 953 } 954 if (localName.equals("session-config") && (sessionConfig==null)) { 955 SessionConfigImpl sessionConfig = SessionConfigImpl.newInstance(); 956 current = getCurrentUNode(); 957 sessionConfig.setParentUNode(current); 958 sessionConfig.setCurrentUNode(sessionConfig); 959 this.setCurrentUNode(sessionConfig); 960 sessionConfig.startElement(namespaceURI, localName, qName, atts); 961 this.sessionConfig = sessionConfig; 963 return; 964 } 965 if (localName.equals("mime-mapping")) { 966 MimeMappingImpl mimeMapping = MimeMappingImpl.newInstance(); 967 current = getCurrentUNode(); 968 mimeMapping.setParentUNode(current); 969 mimeMapping.setCurrentUNode(mimeMapping); 970 this.setCurrentUNode(mimeMapping); 971 mimeMapping.startElement(namespaceURI, localName, qName, atts); 972 mimeMappingList.add(mimeMapping); 974 return; 975 } 976 if (localName.equals("welcome-file-list") && (welcomeFileList==null)) { 977 WelcomeFileListImpl welcomeFileList = WelcomeFileListImpl.newInstance(); 978 current = getCurrentUNode(); 979 welcomeFileList.setParentUNode(current); 980 welcomeFileList.setCurrentUNode(welcomeFileList); 981 this.setCurrentUNode(welcomeFileList); 982 welcomeFileList.startElement(namespaceURI, localName, qName, atts); 983 this.welcomeFileList = welcomeFileList; 985 return; 986 } 987 if (localName.equals("error-page")) { 988 ErrorPageImpl errorPage = ErrorPageImpl.newInstance(); 989 current = getCurrentUNode(); 990 errorPage.setParentUNode(current); 991 errorPage.setCurrentUNode(errorPage); 992 this.setCurrentUNode(errorPage); 993 errorPage.startElement(namespaceURI, localName, qName, atts); 994 errorPageList.add(errorPage); 996 return; 997 } 998 if (localName.equals("taglib")) { 999 TaglibImpl taglib = TaglibImpl.newInstance(); 1000 current = getCurrentUNode(); 1001 taglib.setParentUNode(current); 1002 taglib.setCurrentUNode(taglib); 1003 this.setCurrentUNode(taglib); 1004 taglib.startElement(namespaceURI, localName, qName, atts); 1005 taglibList.add(taglib); 1007 return; 1008 } 1009 if (localName.equals("resource-env-ref")) { 1010 ResourceEnvRefImpl resourceEnvRef = ResourceEnvRefImpl.newInstance(); 1011 current = getCurrentUNode(); 1012 resourceEnvRef.setParentUNode(current); 1013 resourceEnvRef.setCurrentUNode(resourceEnvRef); 1014 this.setCurrentUNode(resourceEnvRef); 1015 resourceEnvRef.startElement(namespaceURI, localName, qName, atts); 1016 resourceEnvRefList.add(resourceEnvRef); 1018 return; 1019 } 1020 if (localName.equals("resource-ref")) { 1021 ResourceRefImpl resourceRef = ResourceRefImpl.newInstance(); 1022 current = getCurrentUNode(); 1023 resourceRef.setParentUNode(current); 1024 resourceRef.setCurrentUNode(resourceRef); 1025 this.setCurrentUNode(resourceRef); 1026 resourceRef.startElement(namespaceURI, localName, qName, atts); 1027 resourceRefList.add(resourceRef); 1029 return; 1030 } 1031 if (localName.equals("security-constraint")) { 1032 SecurityConstraintImpl securityConstraint = SecurityConstraintImpl.newInstance(); 1033 current = getCurrentUNode(); 1034 securityConstraint.setParentUNode(current); 1035 securityConstraint.setCurrentUNode(securityConstraint); 1036 this.setCurrentUNode(securityConstraint); 1037 securityConstraint.startElement(namespaceURI, localName, qName, atts); 1038 securityConstraintList.add(securityConstraint); 1040 return; 1041 } 1042 if (localName.equals("login-config") && (loginConfig==null)) { 1043 LoginConfigImpl loginConfig = LoginConfigImpl.newInstance(); 1044 current = getCurrentUNode(); 1045 loginConfig.setParentUNode(current); 1046 loginConfig.setCurrentUNode(loginConfig); 1047 this.setCurrentUNode(loginConfig); 1048 loginConfig.startElement(namespaceURI, localName, qName, atts); 1049 this.loginConfig = loginConfig; 1051 return; 1052 } 1053 if (localName.equals("security-role")) { 1054 SecurityRoleImpl securityRole = SecurityRoleImpl.newInstance(); 1055 current = getCurrentUNode(); 1056 securityRole.setParentUNode(current); 1057 securityRole.setCurrentUNode(securityRole); 1058 this.setCurrentUNode(securityRole); 1059 securityRole.startElement(namespaceURI, localName, qName, atts); 1060 securityRoleList.add(securityRole); 1062 return; 1063 } 1064 if (localName.equals("env-entry")) { 1065 EnvEntryImpl envEntry = EnvEntryImpl.newInstance(); 1066 current = getCurrentUNode(); 1067 envEntry.setParentUNode(current); 1068 envEntry.setCurrentUNode(envEntry); 1069 this.setCurrentUNode(envEntry); 1070 envEntry.startElement(namespaceURI, localName, qName, atts); 1071 envEntryList.add(envEntry); 1073 return; 1074 } 1075 if (localName.equals("ejb-ref")) { 1076 EjbRefImpl ejbRef = EjbRefImpl.newInstance(); 1077 current = getCurrentUNode(); 1078 ejbRef.setParentUNode(current); 1079 ejbRef.setCurrentUNode(ejbRef); 1080 this.setCurrentUNode(ejbRef); 1081 ejbRef.startElement(namespaceURI, localName, qName, atts); 1082 ejbRefList.add(ejbRef); 1084 return; 1085 } 1086 if (localName.equals("ejb-local-ref")) { 1087 EjbLocalRefImpl ejbLocalRef = EjbLocalRefImpl.newInstance(); 1088 current = getCurrentUNode(); 1089 ejbLocalRef.setParentUNode(current); 1090 ejbLocalRef.setCurrentUNode(ejbLocalRef); 1091 this.setCurrentUNode(ejbLocalRef); 1092 ejbLocalRef.startElement(namespaceURI, localName, qName, atts); 1093 ejbLocalRefList.add(ejbLocalRef); 1095 return; 1096 } 1097 } 1098 } 1099 1100 public void endElement(String namespaceURI, String localName, 1101 String qName) 1102 throws SAXException { 1103 1104 Unmarshallable current = getCurrentUNode(); 1105 if (current != this) { 1106 current.endElement(namespaceURI, localName, qName); 1107 return; 1108 } 1109 1110 Unmarshallable parent = getCurrentUNode().getParentUNode(); 1111 if (parent != null) { 1112 parent.setCurrentUNode(parent); 1113 } 1114 } 1115 1116 public void characters(char[] ch, int start, int len) 1117 throws SAXException { 1118 1119 Unmarshallable current = getCurrentUNode(); 1121 if (current != this) { 1122 current.characters(ch, start, len); 1123 return; 1124 } 1125 1126 String text = new String (ch, start, len); 1127 } 1128 1129 public void comment(char ch[], int start, int len) throws SAXException { 1130 } 1132 1133 public void warning(SAXParseException e) throws SAXException { 1134 if (errorHandler != null) { 1135 errorHandler.warning(e); 1136 } 1137 } 1138 1139 public void error(SAXParseException e) throws SAXException { 1140 if ((validate) && (!hasDTD)) { 1141 throw new SAXException ("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference."); 1142 } 1143 if (errorHandler != null) { 1144 errorHandler.error(e); 1145 } 1146 } 1147 1148 public void fatalError(SAXParseException e) throws SAXException { 1149 if ((validate) && (!hasDTD)) { 1150 throw new SAXException ("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference."); 1151 } 1152 if (errorHandler != null) { 1153 errorHandler.fatalError(e); 1154 } 1155 } 1156 1157 public void startDTD(String name, String publicID, String systemID) 1158 throws SAXException { 1159 1160 if ((name == null) || (name.equals(""))) { 1161 docTypeString = ""; 1162 return; 1163 } 1164 1165 hasDTD = true; 1166 StringBuffer docTypeSB = new StringBuffer (); 1167 boolean hasPublic = false; 1168 1169 docTypeSB.append("<!DOCTYPE ") 1170 .append(name); 1171 1172 if ((publicID != null) && (!publicID.equals(""))) { 1173 docTypeSB.append(" PUBLIC \"") 1174 .append(publicID) 1175 .append("\""); 1176 hasPublic = true; 1177 } 1178 1179 if ((systemID != null) && (!systemID.equals(""))) { 1180 if (!hasPublic) { 1181 docTypeSB.append(" SYSTEM"); 1182 } 1183 docTypeSB.append(" \"") 1184 .append(systemID) 1185 .append("\""); 1186 1187 } 1188 1189 docTypeSB.append(">"); 1190 1191 docTypeString = docTypeSB.toString(); 1192 } 1193 1194 public void endDTD() throws SAXException { 1195 } 1197 1198 public void startEntity(String name) throws SAXException { 1199 } 1201 1202 public void endEntity(String name) throws SAXException { 1203 } 1205 1206 public void startCDATA() throws SAXException { 1207 } 1209 1210 public void endCDATA() throws SAXException { 1211 } 1213 1214} 1215 | Popular Tags |