KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > convert > xml > ServletImpl


1 /**
2  * This class was generated from a set of XML constraints
3  * by the Enhydra Zeus XML Data Binding Framework. All
4  * source code in this file is constructed specifically
5  * to work with other Zeus-generated classes. If you
6  * modify this file by hand, you run the risk of breaking
7  * this interoperation, as well as introducing errors in
8  * source code compilation.
9  *
10  * * * * * MODIFY THIS FILE AT YOUR OWN RISK * * * * *
11  *
12  * To find out more about the Enhydra Zeus framework, you
13  * can point your browser at <http://zeus.enhydra.org>
14  * where you can download releases, join and discuss Zeus
15  * on user and developer mailing lists, and access source
16  * code. Please report any bugs through that website.
17  */

18 package org.enhydra.convert.xml;
19
20 // Global Implementation Import Statements
21
import java.io.File JavaDoc;
22 import java.io.FileReader JavaDoc;
23 import java.io.FileWriter JavaDoc;
24 import java.io.InputStream JavaDoc;
25 import java.io.InputStreamReader JavaDoc;
26 import java.io.IOException JavaDoc;
27 import java.io.OutputStream JavaDoc;
28 import java.io.OutputStreamWriter JavaDoc;
29 import java.io.Reader JavaDoc;
30 import java.io.Writer JavaDoc;
31 import java.util.HashMap JavaDoc;
32 import java.util.Iterator JavaDoc;
33 import java.util.Map JavaDoc;
34 import org.xml.sax.EntityResolver JavaDoc;
35 import org.xml.sax.ErrorHandler JavaDoc;
36 import org.xml.sax.InputSource JavaDoc;
37 import org.xml.sax.Locator JavaDoc;
38 import org.xml.sax.SAXException JavaDoc;
39 import org.xml.sax.SAXParseException JavaDoc;
40 import org.xml.sax.XMLReader JavaDoc;
41 import org.xml.sax.ext.LexicalHandler JavaDoc;
42 import org.xml.sax.helpers.DefaultHandler JavaDoc;
43 import org.xml.sax.helpers.XMLReaderFactory JavaDoc;
44
45 // Local Implementation Import Statements
46
import java.util.Iterator JavaDoc;
47 import java.util.List JavaDoc;
48 import java.util.LinkedList JavaDoc;
49
50 public class ServletImpl extends DefaultHandler JavaDoc implements Cloneable JavaDoc, Unmarshallable, LexicalHandler JavaDoc, Servlet {
51
52     private Icon icon;
53     private ServletName servletName;
54     private DisplayName displayName;
55     private Description description;
56     private ServletClass servletClass;
57     private JspFile jspFile;
58     private List JavaDoc initParamList;
59     private LoadOnStartup loadOnStartup;
60     private RunAs runAs;
61     private List JavaDoc securityRoleRefList;
62     private String JavaDoc id;
63     private boolean zeus_IdSet;
64
65     /** Any DOCTYPE reference/statements. */
66     private String JavaDoc docTypeString;
67
68     /** The encoding for the output document */
69     private String JavaDoc outputEncoding;
70
71     /** The current node in unmarshalling */
72     private Unmarshallable zeus_currentUNode;
73
74     /** The parent node in unmarshalling */
75     private Unmarshallable zeus_parentUNode;
76
77     /** Whether this node has been handled */
78     private boolean zeus_thisNodeHandled = false;
79
80     /** Whether a DTD exists for an unmarshal call */
81     private boolean hasDTD;
82
83     /** Whether validation is occurring */
84     private boolean validate;
85
86     /** The namespace mappings on this element */
87     private Map JavaDoc namespaceMappings;
88
89     /** The EntityResolver for SAX parsing to use */
90     private static EntityResolver JavaDoc entityResolver;
91
92     /** The ErrorHandler for SAX parsing to use */
93     private static ErrorHandler JavaDoc errorHandler;
94
95     private static ServletImpl prototype = null;
96
97     public static void setPrototype(ServletImpl prototype) {
98         ServletImpl.prototype = prototype;
99     }
100     public static ServletImpl newInstance() {
101         try {
102             return (prototype!=null)?(ServletImpl)prototype.clone(): new ServletImpl();
103         } catch (CloneNotSupportedException JavaDoc e) {
104             return null; // never
105
}
106     }
107     public ServletImpl() {
108         initParamList = new LinkedList JavaDoc();
109         securityRoleRefList = new LinkedList JavaDoc();
110         zeus_IdSet = false;
111         docTypeString = "";
112         hasDTD = false;
113         validate = false;
114         namespaceMappings = new HashMap JavaDoc();
115     }
116
117     public Icon getIcon() {
118         return icon;
119     }
120
121     public void setIcon(Icon icon) {
122         this.icon = icon;
123     }
124
125     public ServletName getServletName() {
126         return servletName;
127     }
128
129     public void setServletName(ServletName servletName) {
130         this.servletName = servletName;
131     }
132
133     public DisplayName getDisplayName() {
134         return displayName;
135     }
136
137     public void setDisplayName(DisplayName displayName) {
138         this.displayName = displayName;
139     }
140
141     public Description getDescription() {
142         return description;
143     }
144
145     public void setDescription(Description description) {
146         this.description = description;
147     }
148
149     public ServletClass getServletClass() {
150         return servletClass;
151     }
152
153     public void setServletClass(ServletClass servletClass) {
154         this.servletClass = servletClass;
155     }
156
157     public JspFile getJspFile() {
158         return jspFile;
159     }
160
161     public void setJspFile(JspFile jspFile) {
162         this.jspFile = jspFile;
163     }
164
165     public List JavaDoc getInitParamList() {
166         return initParamList;
167     }
168
169     public void setInitParamList(List JavaDoc initParamList) {
170         this.initParamList = initParamList;
171     }
172
173     public void addInitParam(InitParam initParam) {
174         initParamList.add(initParam);
175     }
176
177     public void removeInitParam(InitParam initParam) {
178         initParamList.remove(initParam);
179     }
180
181     public LoadOnStartup getLoadOnStartup() {
182         return loadOnStartup;
183     }
184
185     public void setLoadOnStartup(LoadOnStartup loadOnStartup) {
186         this.loadOnStartup = loadOnStartup;
187     }
188
189     public RunAs getRunAs() {
190         return runAs;
191     }
192
193     public void setRunAs(RunAs runAs) {
194         this.runAs = runAs;
195     }
196
197     public List JavaDoc getSecurityRoleRefList() {
198         return securityRoleRefList;
199     }
200
201     public void setSecurityRoleRefList(List JavaDoc securityRoleRefList) {
202         this.securityRoleRefList = securityRoleRefList;
203     }
204
205     public void addSecurityRoleRef(SecurityRoleRef securityRoleRef) {
206         securityRoleRefList.add(securityRoleRef);
207     }
208
209     public void removeSecurityRoleRef(SecurityRoleRef securityRoleRef) {
210         securityRoleRefList.remove(securityRoleRef);
211     }
212
213     public String JavaDoc getId() {
214         return id;
215     }
216
217     public void setId(String JavaDoc id) {
218         this.id = id;
219         zeus_IdSet = true;
220     }
221
222     public void setDocType(String JavaDoc name, String JavaDoc publicID, String JavaDoc systemID) {
223         try {
224             startDTD(name, publicID, systemID);
225         } catch (SAXException JavaDoc neverHappens) { }
226     }
227
228     public void setOutputEncoding(String JavaDoc outputEncoding) {
229         this.outputEncoding = outputEncoding;
230     }
231
232     public void marshal(File JavaDoc file) throws IOException JavaDoc {
233         // Delegate to the marshal(Writer) method
234
marshal(new FileWriter JavaDoc(file));
235     }
236
237     public void marshal(OutputStream JavaDoc outputStream) throws IOException JavaDoc {
238         // Delegate to the marshal(Writer) method
239
marshal(new OutputStreamWriter JavaDoc(outputStream));
240     }
241
242     public void marshal(Writer JavaDoc writer) throws IOException JavaDoc {
243         // Write out the XML declaration
244
writer.write("<?xml version=\"1.0\" ");
245         if (outputEncoding != null) {
246             writer.write("encoding=\"");
247             writer.write(outputEncoding);
248             writer.write("\"?>\n\n");
249
250         } else {
251             writer.write("encoding=\"UTF-8\"?>\n\n");
252
253         }
254         // Handle DOCTYPE declaration
255
writer.write(docTypeString);
256         writer.write("\n");
257         // Now start the recursive writing
258
writeXMLRepresentation(writer, "");
259
260         // Close up
261
writer.flush();
262         writer.close();
263     }
264
265     protected void writeXMLRepresentation(Writer JavaDoc writer,
266                                           String JavaDoc indent)
267         throws IOException JavaDoc {
268
269         writer.write(indent);
270         writer.write("<servlet");
271
272         // Handle namespace mappings (if needed)
273
for (Iterator JavaDoc i = namespaceMappings.keySet().iterator(); i.hasNext(); ) {
274             String JavaDoc prefix = (String JavaDoc)i.next();
275             String JavaDoc uri = (String JavaDoc)namespaceMappings.get(prefix);
276             writer.write(" xmlns");
277             if (!prefix.trim().equals("")) {
278                 writer.write(":");
279                 writer.write(prefix);
280             }
281             writer.write("=\"");
282             writer.write(uri);
283             writer.write("\"\n ");
284         }
285
286         // Handle attributes (if needed)
287
if (zeus_IdSet) {
288             writer.write(" id=\"");
289             writer.write(escapeAttributeValue(id));
290             writer.write("\"");
291         }
292         writer.write(">");
293         writer.write("\n");
294
295         // Handle child elements
296
if (icon != null) {
297             ((IconImpl)icon).writeXMLRepresentation(writer,
298                 new StringBuffer JavaDoc(indent).append(" ").toString());
299         }
300
301         if (servletName != null) {
302             ((ServletNameImpl)servletName).writeXMLRepresentation(writer,
303                 new StringBuffer JavaDoc(indent).append(" ").toString());
304         }
305
306         if (displayName != null) {
307             ((DisplayNameImpl)displayName).writeXMLRepresentation(writer,
308                 new StringBuffer JavaDoc(indent).append(" ").toString());
309         }
310
311         if (description != null) {
312             ((DescriptionImpl)description).writeXMLRepresentation(writer,
313                 new StringBuffer JavaDoc(indent).append(" ").toString());
314         }
315
316         if (servletClass != null) {
317             ((ServletClassImpl)servletClass).writeXMLRepresentation(writer,
318                 new StringBuffer JavaDoc(indent).append(" ").toString());
319         }
320
321         if (jspFile != null) {
322             ((JspFileImpl)jspFile).writeXMLRepresentation(writer,
323                 new StringBuffer JavaDoc(indent).append(" ").toString());
324         }
325
326         for (Iterator JavaDoc i=initParamList.iterator(); i.hasNext(); ) {
327             InitParamImpl initParam = (InitParamImpl)i.next();
328             initParam.writeXMLRepresentation(writer,
329                 new StringBuffer JavaDoc(indent).append(" ").toString());
330         }
331         if (loadOnStartup != null) {
332             ((LoadOnStartupImpl)loadOnStartup).writeXMLRepresentation(writer,
333                 new StringBuffer JavaDoc(indent).append(" ").toString());
334         }
335
336         if (runAs != null) {
337             ((RunAsImpl)runAs).writeXMLRepresentation(writer,
338                 new StringBuffer JavaDoc(indent).append(" ").toString());
339         }
340
341         for (Iterator JavaDoc i=securityRoleRefList.iterator(); i.hasNext(); ) {
342             SecurityRoleRefImpl securityRoleRef = (SecurityRoleRefImpl)i.next();
343             securityRoleRef.writeXMLRepresentation(writer,
344                 new StringBuffer JavaDoc(indent).append(" ").toString());
345         }
346         writer.write(indent);
347         writer.write("</servlet>\n");
348     }
349
350     private String JavaDoc escapeAttributeValue(String JavaDoc attributeValue) {
351         String JavaDoc returnValue = attributeValue;
352         for (int i = 0; i < returnValue.length(); i++) {
353             char ch = returnValue.charAt(i);
354             if (ch == '"') {
355                 returnValue = new StringBuffer JavaDoc()
356                     .append(returnValue.substring(0, i))
357                     .append("&quot;")
358                     .append(returnValue.substring(i+1))
359                     .toString();
360             }
361         }
362         return returnValue;
363     }
364
365     private String JavaDoc escapeTextValue(String JavaDoc textValue) {
366         String JavaDoc returnValue = textValue;
367         for (int i = 0; i < returnValue.length(); i++) {
368             char ch = returnValue.charAt(i);
369             if (ch == '<') {
370                 returnValue = new StringBuffer JavaDoc()
371                     .append(returnValue.substring(0, i))
372                     .append("&lt;")
373                     .append(returnValue.substring(i+1))
374                     .toString();
375             } else if (ch == '>') {
376                 returnValue = new StringBuffer JavaDoc()
377                     .append(returnValue.substring(0, i))
378                     .append("&gt;")
379                     .append(returnValue.substring(i+1))
380                     .toString();
381             }
382         }
383         return returnValue;
384     }
385
386     /**
387      * <p>
388      * This sets a SAX <code>EntityResolver</code> for this unmarshalling process.
389      * </p>
390      *
391      * @param resolver the entity resolver to use.
392      */

393     public static void setEntityResolver(EntityResolver JavaDoc resolver) {
394         entityResolver = resolver;
395     }
396
397     /**
398      * <p>
399      * This sets a SAX <code>ErrorHandler</code> for this unmarshalling process.
400      * </p>
401      *
402      * @param handler the entity resolver to use.
403      */

404     public static void setErrorHandler(ErrorHandler JavaDoc handler) {
405         errorHandler = handler;
406     }
407
408     public static Servlet unmarshal(File JavaDoc file) throws IOException JavaDoc {
409         // Delegate to the unmarshal(Reader) method
410
return unmarshal(new FileReader JavaDoc(file));
411     }
412
413     public static Servlet unmarshal(File JavaDoc file, boolean validate) throws IOException JavaDoc {
414         // Delegate to the unmarshal(Reader) method
415
return unmarshal(new FileReader JavaDoc(file), validate);
416     }
417
418     public static Servlet unmarshal(InputStream JavaDoc inputStream) throws IOException JavaDoc {
419         // Delegate to the unmarshal(Reader) method
420
return unmarshal(new InputStreamReader JavaDoc(inputStream));
421     }
422
423     public static Servlet unmarshal(InputStream JavaDoc inputStream, boolean validate) throws IOException JavaDoc {
424         // Delegate to the unmarshal(Reader) method
425
return unmarshal(new InputStreamReader JavaDoc(inputStream), validate);
426     }
427
428     public static Servlet unmarshal(Reader JavaDoc reader) throws IOException JavaDoc {
429         // Delegate with default validation value
430
return unmarshal(reader, false);
431     }
432
433     public static Servlet unmarshal(Reader JavaDoc reader, boolean validate) throws IOException JavaDoc {
434         ServletImpl servlet = ServletImpl.newInstance();
435         servlet.setValidating(validate);
436         servlet.setCurrentUNode(servlet);
437         servlet.setParentUNode(null);
438         // Load the XML parser
439
XMLReader JavaDoc parser = null;
440         String JavaDoc parserClass = System.getProperty("org.xml.sax.driver",
441             "org.apache.xerces.parsers.SAXParser");
442         try {
443             parser = XMLReaderFactory.createXMLReader(parserClass);
444
445             // Set entity resolver, if needed
446
if (entityResolver != null) {
447                 parser.setEntityResolver(entityResolver);
448             }
449
450             // Set error handler
451
parser.setErrorHandler(servlet);
452
453             // Register lexical handler
454
parser.setProperty("http://xml.org/sax/properties/lexical-handler", servlet);
455
456             // Register content handler
457
parser.setContentHandler(servlet);
458         } catch (SAXException JavaDoc e) {
459             throw new IOException JavaDoc("Could not load XML parser: " +
460                 e.getMessage());
461         }
462
463         InputSource JavaDoc inputSource = new InputSource JavaDoc(reader);
464         try {
465             parser.setFeature("http://xml.org/sax/features/validation", new Boolean JavaDoc(validate).booleanValue());
466             parser.setFeature("http://xml.org/sax/features/namespaces", true);
467             parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
468             parser.parse(inputSource);
469         } catch (SAXException JavaDoc e) {
470             throw new IOException JavaDoc("Error parsing XML document: " +
471                 e.getMessage());
472         }
473
474         // Return the resultant object
475
return servlet;
476     }
477
478     public Unmarshallable getParentUNode() {
479         return zeus_parentUNode;
480     }
481
482     public void setParentUNode(Unmarshallable parentUNode) {
483         this.zeus_parentUNode = parentUNode;
484     }
485
486     public Unmarshallable getCurrentUNode() {
487         return zeus_currentUNode;
488     }
489
490     public void setCurrentUNode(Unmarshallable currentUNode) {
491         this.zeus_currentUNode = currentUNode;
492     }
493
494     public void setValidating(boolean validate) {
495         this.validate = validate;
496     }
497
498     public void startDocument() throws SAXException JavaDoc {
499         // no-op
500
}
501
502     public void setDocumentLocator(Locator JavaDoc locator) {
503         // no-op
504
}
505
506     public void startPrefixMapping(String JavaDoc prefix, String JavaDoc uri)
507         throws SAXException JavaDoc {
508         namespaceMappings.put(prefix, uri);
509     }
510
511     public void startElement(String JavaDoc namespaceURI, String JavaDoc localName,
512                              String JavaDoc qName, org.xml.sax.Attributes JavaDoc atts)
513         throws SAXException JavaDoc {
514
515         // Feed this to the correct ContentHandler
516
Unmarshallable current = getCurrentUNode();
517         if (current != this) {
518             current.startElement(namespaceURI, localName, qName, atts);
519             return;
520         }
521
522         // See if we handle, or we delegate
523
if ((localName.equals("servlet")) && (!zeus_thisNodeHandled)) {
524             // Handle ourselves
525
for (int i=0, len=atts.getLength(); i<len; i++) {
526                 String JavaDoc attName= atts.getLocalName(i);
527                 String JavaDoc attValue = atts.getValue(i);
528                 if (attName.equals("id")) {
529                     setId(attValue);
530                 }
531             }
532             zeus_thisNodeHandled = true;
533             return;
534         } else {
535             // Delegate handling
536
if (localName.equals("icon") && (icon==null)) {
537                 IconImpl icon = IconImpl.newInstance();
538                 current = getCurrentUNode();
539                 icon.setParentUNode(current);
540                 icon.setCurrentUNode(icon);
541                 this.setCurrentUNode(icon);
542                 icon.startElement(namespaceURI, localName, qName, atts);
543                 // Add this value in
544
this.icon = icon;
545                 return;
546             }
547             if (localName.equals("servlet-name") && (servletName==null)) {
548                 ServletNameImpl servletName = ServletNameImpl.newInstance();
549                 current = getCurrentUNode();
550                 servletName.setParentUNode(current);
551                 servletName.setCurrentUNode(servletName);
552                 this.setCurrentUNode(servletName);
553                 servletName.startElement(namespaceURI, localName, qName, atts);
554                 // Add this value in
555
this.servletName = servletName;
556                 return;
557             }
558             if (localName.equals("display-name") && (displayName==null)) {
559                 DisplayNameImpl displayName = DisplayNameImpl.newInstance();
560                 current = getCurrentUNode();
561                 displayName.setParentUNode(current);
562                 displayName.setCurrentUNode(displayName);
563                 this.setCurrentUNode(displayName);
564                 displayName.startElement(namespaceURI, localName, qName, atts);
565                 // Add this value in
566
this.displayName = displayName;
567                 return;
568             }
569             if (localName.equals("description") && (description==null)) {
570                 DescriptionImpl description = DescriptionImpl.newInstance();
571                 current = getCurrentUNode();
572                 description.setParentUNode(current);
573                 description.setCurrentUNode(description);
574                 this.setCurrentUNode(description);
575                 description.startElement(namespaceURI, localName, qName, atts);
576                 // Add this value in
577
this.description = description;
578                 return;
579             }
580             if (localName.equals("servlet-class") && (servletClass==null)) {
581                 ServletClassImpl servletClass = ServletClassImpl.newInstance();
582                 current = getCurrentUNode();
583                 servletClass.setParentUNode(current);
584                 servletClass.setCurrentUNode(servletClass);
585                 this.setCurrentUNode(servletClass);
586                 servletClass.startElement(namespaceURI, localName, qName, atts);
587                 // Add this value in
588
this.servletClass = servletClass;
589                 return;
590             }
591             if (localName.equals("jsp-file") && (jspFile==null)) {
592                 JspFileImpl jspFile = JspFileImpl.newInstance();
593                 current = getCurrentUNode();
594                 jspFile.setParentUNode(current);
595                 jspFile.setCurrentUNode(jspFile);
596                 this.setCurrentUNode(jspFile);
597                 jspFile.startElement(namespaceURI, localName, qName, atts);
598                 // Add this value in
599
this.jspFile = jspFile;
600                 return;
601             }
602             if (localName.equals("init-param")) {
603                 InitParamImpl initParam = InitParamImpl.newInstance();
604                 current = getCurrentUNode();
605                 initParam.setParentUNode(current);
606                 initParam.setCurrentUNode(initParam);
607                 this.setCurrentUNode(initParam);
608                 initParam.startElement(namespaceURI, localName, qName, atts);
609                 // Add this value in
610
initParamList.add(initParam);
611                 return;
612             }
613             if (localName.equals("load-on-startup") && (loadOnStartup==null)) {
614                 LoadOnStartupImpl loadOnStartup = LoadOnStartupImpl.newInstance();
615                 current = getCurrentUNode();
616                 loadOnStartup.setParentUNode(current);
617                 loadOnStartup.setCurrentUNode(loadOnStartup);
618                 this.setCurrentUNode(loadOnStartup);
619                 loadOnStartup.startElement(namespaceURI, localName, qName, atts);
620                 // Add this value in
621
this.loadOnStartup = loadOnStartup;
622                 return;
623             }
624             if (localName.equals("run-as") && (runAs==null)) {
625                 RunAsImpl runAs = RunAsImpl.newInstance();
626                 current = getCurrentUNode();
627                 runAs.setParentUNode(current);
628                 runAs.setCurrentUNode(runAs);
629                 this.setCurrentUNode(runAs);
630                 runAs.startElement(namespaceURI, localName, qName, atts);
631                 // Add this value in
632
this.runAs = runAs;
633                 return;
634             }
635             if (localName.equals("security-role-ref")) {
636                 SecurityRoleRefImpl securityRoleRef = SecurityRoleRefImpl.newInstance();
637                 current = getCurrentUNode();
638                 securityRoleRef.setParentUNode(current);
639                 securityRoleRef.setCurrentUNode(securityRoleRef);
640                 this.setCurrentUNode(securityRoleRef);
641                 securityRoleRef.startElement(namespaceURI, localName, qName, atts);
642                 // Add this value in
643
securityRoleRefList.add(securityRoleRef);
644                 return;
645             }
646         }
647     }
648
649     public void endElement(String JavaDoc namespaceURI, String JavaDoc localName,
650                            String JavaDoc qName)
651         throws SAXException JavaDoc {
652
653         Unmarshallable current = getCurrentUNode();
654         if (current != this) {
655             current.endElement(namespaceURI, localName, qName);
656             return;
657         }
658
659         Unmarshallable parent = getCurrentUNode().getParentUNode();
660         if (parent != null) {
661             parent.setCurrentUNode(parent);
662         }
663     }
664
665     public void characters(char[] ch, int start, int len)
666         throws SAXException JavaDoc {
667
668         // Feed this to the correct ContentHandler
669
Unmarshallable current = getCurrentUNode();
670         if (current != this) {
671             current.characters(ch, start, len);
672             return;
673         }
674
675         String JavaDoc text = new String JavaDoc(ch, start, len);
676     }
677
678     public void comment(char ch[], int start, int len) throws SAXException JavaDoc {
679         // Currently no-op
680
}
681
682     public void warning(SAXParseException JavaDoc e) throws SAXException JavaDoc {
683         if (errorHandler != null) {
684             errorHandler.warning(e);
685         }
686     }
687
688     public void error(SAXParseException JavaDoc e) throws SAXException JavaDoc {
689         if ((validate) && (!hasDTD)) {
690             throw new SAXException JavaDoc("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");
691         }
692         if (errorHandler != null) {
693             errorHandler.error(e);
694         }
695     }
696
697     public void fatalError(SAXParseException JavaDoc e) throws SAXException JavaDoc {
698         if ((validate) && (!hasDTD)) {
699             throw new SAXException JavaDoc("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");
700         }
701         if (errorHandler != null) {
702             errorHandler.fatalError(e);
703         }
704     }
705
706     public void startDTD(String JavaDoc name, String JavaDoc publicID, String JavaDoc systemID)
707         throws SAXException JavaDoc {
708
709         if ((name == null) || (name.equals(""))) {
710             docTypeString = "";
711             return;
712         }
713
714         hasDTD = true;
715         StringBuffer JavaDoc docTypeSB = new StringBuffer JavaDoc();
716         boolean hasPublic = false;
717
718         docTypeSB.append("<!DOCTYPE ")
719                  .append(name);
720
721         if ((publicID != null) && (!publicID.equals(""))) {
722             docTypeSB.append(" PUBLIC \"")
723                      .append(publicID)
724                      .append("\"");
725             hasPublic = true;
726         }
727
728         if ((systemID != null) && (!systemID.equals(""))) {
729             if (!hasPublic) {
730                 docTypeSB.append(" SYSTEM");
731             }
732             docTypeSB.append(" \"")
733                      .append(systemID)
734                      .append("\"");
735
736         }
737
738         docTypeSB.append(">");
739
740         docTypeString = docTypeSB.toString();
741     }
742
743     public void endDTD() throws SAXException JavaDoc {
744         // Currently no-op
745
}
746
747     public void startEntity(String JavaDoc name) throws SAXException JavaDoc {
748         // Currently no-op
749
}
750
751     public void endEntity(String JavaDoc name) throws SAXException JavaDoc {
752         // Currently no-op
753
}
754
755     public void startCDATA() throws SAXException JavaDoc {
756         // Currently no-op
757
}
758
759     public void endCDATA() throws SAXException JavaDoc {
760         // Currently no-op
761
}
762
763 }
764
Popular Tags