KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > business > xml > ResultImpl


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.snapper.business.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 public class ResultImpl extends DefaultHandler JavaDoc implements Cloneable JavaDoc, Unmarshallable, LexicalHandler JavaDoc, Result {
46
47     private SiteName siteName;
48     private Title title;
49     private FileType fileType;
50     private FileName fileName;
51     private AbsolutFileName absolutFileName;
52     private AbsolutDirPath absolutDirPath;
53     private AbsolutFilePath absolutFilePath;
54     private RelativeDirPath relativeDirPath;
55     private RelativeFilePath relativeFilePath;
56     private Mapped mapped;
57     private GrantedDownload grantedDownload;
58     private Score score;
59     private Modified modified;
60     private Content content;
61     private Properties properties;
62     private MetaData metaData;
63
64     /** Any DOCTYPE reference/statements. */
65     private String JavaDoc docTypeString;
66
67     /** The encoding for the output document */
68     private String JavaDoc outputEncoding;
69
70     /** The current node in unmarshalling */
71     private Unmarshallable zeus_currentUNode;
72
73     /** The parent node in unmarshalling */
74     private Unmarshallable zeus_parentUNode;
75
76     /** Whether this node has been handled */
77     private boolean zeus_thisNodeHandled = false;
78
79     /** Whether a DTD exists for an unmarshal call */
80     private boolean hasDTD;
81
82     /** Whether validation is occurring */
83     private boolean validate;
84
85     /** The namespace mappings on this element */
86     private Map JavaDoc namespaceMappings;
87
88     /** The EntityResolver for SAX parsing to use */
89     private static EntityResolver JavaDoc entityResolver;
90
91     /** The ErrorHandler for SAX parsing to use */
92     private static ErrorHandler JavaDoc errorHandler;
93
94     private static ResultImpl prototype = null;
95
96     public static void setPrototype(ResultImpl prototype) {
97         ResultImpl.prototype = prototype;
98     }
99     public static ResultImpl newInstance() {
100         try {
101             return (prototype!=null)?(ResultImpl)prototype.clone(): new ResultImpl();
102         } catch (CloneNotSupportedException JavaDoc e) {
103             return null; // never
104
}
105     }
106     public ResultImpl() {
107         docTypeString = "";
108         hasDTD = false;
109         validate = false;
110         namespaceMappings = new HashMap JavaDoc();
111     }
112
113     public SiteName getSiteName() {
114         return siteName;
115     }
116
117     public void setSiteName(SiteName siteName) {
118         this.siteName = siteName;
119     }
120
121     public Title getTitle() {
122         return title;
123     }
124
125     public void setTitle(Title title) {
126         this.title = title;
127     }
128
129     public FileType getFileType() {
130         return fileType;
131     }
132
133     public void setFileType(FileType fileType) {
134         this.fileType = fileType;
135     }
136
137     public FileName getFileName() {
138         return fileName;
139     }
140
141     public void setFileName(FileName fileName) {
142         this.fileName = fileName;
143     }
144
145     public AbsolutFileName getAbsolutFileName() {
146         return absolutFileName;
147     }
148
149     public void setAbsolutFileName(AbsolutFileName absolutFileName) {
150         this.absolutFileName = absolutFileName;
151     }
152
153     public AbsolutDirPath getAbsolutDirPath() {
154         return absolutDirPath;
155     }
156
157     public void setAbsolutDirPath(AbsolutDirPath absolutDirPath) {
158         this.absolutDirPath = absolutDirPath;
159     }
160
161     public AbsolutFilePath getAbsolutFilePath() {
162         return absolutFilePath;
163     }
164
165     public void setAbsolutFilePath(AbsolutFilePath absolutFilePath) {
166         this.absolutFilePath = absolutFilePath;
167     }
168
169     public RelativeDirPath getRelativeDirPath() {
170         return relativeDirPath;
171     }
172
173     public void setRelativeDirPath(RelativeDirPath relativeDirPath) {
174         this.relativeDirPath = relativeDirPath;
175     }
176
177     public RelativeFilePath getRelativeFilePath() {
178         return relativeFilePath;
179     }
180
181     public void setRelativeFilePath(RelativeFilePath relativeFilePath) {
182         this.relativeFilePath = relativeFilePath;
183     }
184
185     public Mapped getMapped() {
186         return mapped;
187     }
188
189     public void setMapped(Mapped mapped) {
190         this.mapped = mapped;
191     }
192
193     public GrantedDownload getGrantedDownload() {
194         return grantedDownload;
195     }
196
197     public void setGrantedDownload(GrantedDownload grantedDownload) {
198         this.grantedDownload = grantedDownload;
199     }
200
201     public Score getScore() {
202         return score;
203     }
204
205     public void setScore(Score score) {
206         this.score = score;
207     }
208
209     public Modified getModified() {
210         return modified;
211     }
212
213     public void setModified(Modified modified) {
214         this.modified = modified;
215     }
216
217     public Content getContent() {
218         return content;
219     }
220
221     public void setContent(Content content) {
222         this.content = content;
223     }
224
225     public Properties getProperties() {
226         return properties;
227     }
228
229     public void setProperties(Properties properties) {
230         this.properties = properties;
231     }
232
233     public MetaData getMetaData() {
234         return metaData;
235     }
236
237     public void setMetaData(MetaData metaData) {
238         this.metaData = metaData;
239     }
240
241     public void setDocType(String JavaDoc name, String JavaDoc publicID, String JavaDoc systemID) {
242         try {
243             startDTD(name, publicID, systemID);
244         } catch (SAXException JavaDoc neverHappens) { }
245     }
246
247     public void setOutputEncoding(String JavaDoc outputEncoding) {
248         this.outputEncoding = outputEncoding;
249     }
250
251     public void marshal(File JavaDoc file) throws IOException JavaDoc {
252         // Delegate to the marshal(Writer) method
253
marshal(new FileWriter JavaDoc(file));
254     }
255
256     public void marshal(OutputStream JavaDoc outputStream) throws IOException JavaDoc {
257         // Delegate to the marshal(Writer) method
258
marshal(new OutputStreamWriter JavaDoc(outputStream));
259     }
260
261     public void marshal(Writer JavaDoc writer) throws IOException JavaDoc {
262         // Write out the XML declaration
263
writer.write("<?xml version=\"1.0\" ");
264         if (outputEncoding != null) {
265             writer.write("encoding=\"");
266             writer.write(outputEncoding);
267             writer.write("\"?>\n\n");
268
269         } else {
270             writer.write("encoding=\"UTF-8\"?>\n\n");
271
272         }
273         // Handle DOCTYPE declaration
274
writer.write(docTypeString);
275         writer.write("\n");
276         // Now start the recursive writing
277
writeXMLRepresentation(writer, "");
278
279         // Close up
280
writer.flush();
281         writer.close();
282     }
283
284     protected void writeXMLRepresentation(Writer JavaDoc writer,
285                                           String JavaDoc indent)
286         throws IOException JavaDoc {
287
288         writer.write(indent);
289         writer.write("<Result");
290
291         // Handle namespace mappings (if needed)
292
for (Iterator JavaDoc i = namespaceMappings.keySet().iterator(); i.hasNext(); ) {
293             String JavaDoc prefix = (String JavaDoc)i.next();
294             String JavaDoc uri = (String JavaDoc)namespaceMappings.get(prefix);
295             writer.write(" xmlns");
296             if (!prefix.trim().equals("")) {
297                 writer.write(":");
298                 writer.write(prefix);
299             }
300             writer.write("=\"");
301             writer.write(uri);
302             writer.write("\"\n ");
303         }
304
305         // Handle attributes (if needed)
306
writer.write(">");
307         writer.write("\n");
308
309         // Handle child elements
310
if (siteName != null) {
311             ((SiteNameImpl)siteName).writeXMLRepresentation(writer,
312                 new StringBuffer JavaDoc(indent).append(" ").toString());
313         }
314
315         if (title != null) {
316             ((TitleImpl)title).writeXMLRepresentation(writer,
317                 new StringBuffer JavaDoc(indent).append(" ").toString());
318         }
319
320         if (fileType != null) {
321             ((FileTypeImpl)fileType).writeXMLRepresentation(writer,
322                 new StringBuffer JavaDoc(indent).append(" ").toString());
323         }
324
325         if (fileName != null) {
326             ((FileNameImpl)fileName).writeXMLRepresentation(writer,
327                 new StringBuffer JavaDoc(indent).append(" ").toString());
328         }
329
330         if (absolutFileName != null) {
331             ((AbsolutFileNameImpl)absolutFileName).writeXMLRepresentation(writer,
332                 new StringBuffer JavaDoc(indent).append(" ").toString());
333         }
334
335         if (absolutDirPath != null) {
336             ((AbsolutDirPathImpl)absolutDirPath).writeXMLRepresentation(writer,
337                 new StringBuffer JavaDoc(indent).append(" ").toString());
338         }
339
340         if (absolutFilePath != null) {
341             ((AbsolutFilePathImpl)absolutFilePath).writeXMLRepresentation(writer,
342                 new StringBuffer JavaDoc(indent).append(" ").toString());
343         }
344
345         if (relativeDirPath != null) {
346             ((RelativeDirPathImpl)relativeDirPath).writeXMLRepresentation(writer,
347                 new StringBuffer JavaDoc(indent).append(" ").toString());
348         }
349
350         if (relativeFilePath != null) {
351             ((RelativeFilePathImpl)relativeFilePath).writeXMLRepresentation(writer,
352                 new StringBuffer JavaDoc(indent).append(" ").toString());
353         }
354
355         if (mapped != null) {
356             ((MappedImpl)mapped).writeXMLRepresentation(writer,
357                 new StringBuffer JavaDoc(indent).append(" ").toString());
358         }
359
360         if (grantedDownload != null) {
361             ((GrantedDownloadImpl)grantedDownload).writeXMLRepresentation(writer,
362                 new StringBuffer JavaDoc(indent).append(" ").toString());
363         }
364
365         if (score != null) {
366             ((ScoreImpl)score).writeXMLRepresentation(writer,
367                 new StringBuffer JavaDoc(indent).append(" ").toString());
368         }
369
370         if (modified != null) {
371             ((ModifiedImpl)modified).writeXMLRepresentation(writer,
372                 new StringBuffer JavaDoc(indent).append(" ").toString());
373         }
374
375         if (content != null) {
376             ((ContentImpl)content).writeXMLRepresentation(writer,
377                 new StringBuffer JavaDoc(indent).append(" ").toString());
378         }
379
380         if (properties != null) {
381             ((PropertiesImpl)properties).writeXMLRepresentation(writer,
382                 new StringBuffer JavaDoc(indent).append(" ").toString());
383         }
384
385         if (metaData != null) {
386             ((MetaDataImpl)metaData).writeXMLRepresentation(writer,
387                 new StringBuffer JavaDoc(indent).append(" ").toString());
388         }
389
390         writer.write(indent);
391         writer.write("</Result>\n");
392     }
393
394     private String JavaDoc escapeAttributeValue(String JavaDoc attributeValue) {
395         String JavaDoc returnValue = attributeValue;
396         for (int i = 0; i < returnValue.length(); i++) {
397             char ch = returnValue.charAt(i);
398             if (ch == '"') {
399                 returnValue = new StringBuffer JavaDoc()
400                     .append(returnValue.substring(0, i))
401                     .append("&quot;")
402                     .append(returnValue.substring(i+1))
403                     .toString();
404             }
405         }
406         return returnValue;
407     }
408
409     private String JavaDoc escapeTextValue(String JavaDoc textValue) {
410         String JavaDoc returnValue = textValue;
411         for (int i = 0; i < returnValue.length(); i++) {
412             char ch = returnValue.charAt(i);
413             if (ch == '<') {
414                 returnValue = new StringBuffer JavaDoc()
415                     .append(returnValue.substring(0, i))
416                     .append("&lt;")
417                     .append(returnValue.substring(i+1))
418                     .toString();
419             } else if (ch == '>') {
420                 returnValue = new StringBuffer JavaDoc()
421                     .append(returnValue.substring(0, i))
422                     .append("&gt;")
423                     .append(returnValue.substring(i+1))
424                     .toString();
425             }
426         }
427         return returnValue;
428     }
429
430     /**
431      * <p>
432      * This sets a SAX <code>EntityResolver</code> for this unmarshalling process.
433      * </p>
434      *
435      * @param resolver the entity resolver to use.
436      */

437     public static void setEntityResolver(EntityResolver JavaDoc resolver) {
438         entityResolver = resolver;
439     }
440
441     /**
442      * <p>
443      * This sets a SAX <code>ErrorHandler</code> for this unmarshalling process.
444      * </p>
445      *
446      * @param handler the entity resolver to use.
447      */

448     public static void setErrorHandler(ErrorHandler JavaDoc handler) {
449         errorHandler = handler;
450     }
451
452     public static Result unmarshal(File JavaDoc file) throws IOException JavaDoc {
453         // Delegate to the unmarshal(Reader) method
454
return unmarshal(new FileReader JavaDoc(file));
455     }
456
457     public static Result unmarshal(File JavaDoc file, boolean validate) throws IOException JavaDoc {
458         // Delegate to the unmarshal(Reader) method
459
return unmarshal(new FileReader JavaDoc(file), validate);
460     }
461
462     public static Result unmarshal(InputStream JavaDoc inputStream) throws IOException JavaDoc {
463         // Delegate to the unmarshal(Reader) method
464
return unmarshal(new InputStreamReader JavaDoc(inputStream));
465     }
466
467     public static Result unmarshal(InputStream JavaDoc inputStream, boolean validate) throws IOException JavaDoc {
468         // Delegate to the unmarshal(Reader) method
469
return unmarshal(new InputStreamReader JavaDoc(inputStream), validate);
470     }
471
472     public static Result unmarshal(Reader JavaDoc reader) throws IOException JavaDoc {
473         // Delegate with default validation value
474
return unmarshal(reader, false);
475     }
476
477     public static Result unmarshal(Reader JavaDoc reader, boolean validate) throws IOException JavaDoc {
478         ResultImpl result = ResultImpl.newInstance();
479         result.setValidating(validate);
480         result.setCurrentUNode(result);
481         result.setParentUNode(null);
482         // Load the XML parser
483
XMLReader JavaDoc parser = null;
484         String JavaDoc parserClass = System.getProperty("org.xml.sax.driver",
485             "org.apache.xerces.parsers.SAXParser");
486         try {
487             parser = XMLReaderFactory.createXMLReader(parserClass);
488
489             // Set entity resolver, if needed
490
if (entityResolver != null) {
491                 parser.setEntityResolver(entityResolver);
492             }
493
494             // Set error handler
495
parser.setErrorHandler(result);
496
497             // Register lexical handler
498
parser.setProperty("http://xml.org/sax/properties/lexical-handler", result);
499
500             // Register content handler
501
parser.setContentHandler(result);
502         } catch (SAXException JavaDoc e) {
503             throw new IOException JavaDoc("Could not load XML parser: " +
504                 e.getMessage());
505         }
506
507         InputSource JavaDoc inputSource = new InputSource JavaDoc(reader);
508         try {
509             parser.setFeature("http://xml.org/sax/features/validation", new Boolean JavaDoc(validate).booleanValue());
510             parser.setFeature("http://xml.org/sax/features/namespaces", true);
511             parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
512             parser.parse(inputSource);
513         } catch (SAXException JavaDoc e) {
514             throw new IOException JavaDoc("Error parsing XML document: " +
515                 e.getMessage());
516         }
517
518         // Return the resultant object
519
return result;
520     }
521
522     public Unmarshallable getParentUNode() {
523         return zeus_parentUNode;
524     }
525
526     public void setParentUNode(Unmarshallable parentUNode) {
527         this.zeus_parentUNode = parentUNode;
528     }
529
530     public Unmarshallable getCurrentUNode() {
531         return zeus_currentUNode;
532     }
533
534     public void setCurrentUNode(Unmarshallable currentUNode) {
535         this.zeus_currentUNode = currentUNode;
536     }
537
538     public void setValidating(boolean validate) {
539         this.validate = validate;
540     }
541
542     public void startDocument() throws SAXException JavaDoc {
543         // no-op
544
}
545
546     public void setDocumentLocator(Locator JavaDoc locator) {
547         // no-op
548
}
549
550     public void startPrefixMapping(String JavaDoc prefix, String JavaDoc uri)
551         throws SAXException JavaDoc {
552         namespaceMappings.put(prefix, uri);
553     }
554
555     public void startElement(String JavaDoc namespaceURI, String JavaDoc localName,
556                              String JavaDoc qName, org.xml.sax.Attributes JavaDoc atts)
557         throws SAXException JavaDoc {
558
559         // Feed this to the correct ContentHandler
560
Unmarshallable current = getCurrentUNode();
561         if (current != this) {
562             current.startElement(namespaceURI, localName, qName, atts);
563             return;
564         }
565
566         // See if we handle, or we delegate
567
if ((localName.equals("Result")) && (!zeus_thisNodeHandled)) {
568             // Handle ourselves
569
for (int i=0, len=atts.getLength(); i<len; i++) {
570                 String JavaDoc attName= atts.getLocalName(i);
571                 String JavaDoc attValue = atts.getValue(i);
572             }
573             zeus_thisNodeHandled = true;
574             return;
575         } else {
576             // Delegate handling
577
if (localName.equals("SiteName") && (siteName==null)) {
578                 SiteNameImpl siteName = SiteNameImpl.newInstance();
579                 current = getCurrentUNode();
580                 siteName.setParentUNode(current);
581                 siteName.setCurrentUNode(siteName);
582                 this.setCurrentUNode(siteName);
583                 siteName.startElement(namespaceURI, localName, qName, atts);
584                 // Add this value in
585
this.siteName = siteName;
586                 return;
587             }
588             if (localName.equals("Title") && (title==null)) {
589                 TitleImpl title = TitleImpl.newInstance();
590                 current = getCurrentUNode();
591                 title.setParentUNode(current);
592                 title.setCurrentUNode(title);
593                 this.setCurrentUNode(title);
594                 title.startElement(namespaceURI, localName, qName, atts);
595                 // Add this value in
596
this.title = title;
597                 return;
598             }
599             if (localName.equals("FileType") && (fileType==null)) {
600                 FileTypeImpl fileType = FileTypeImpl.newInstance();
601                 current = getCurrentUNode();
602                 fileType.setParentUNode(current);
603                 fileType.setCurrentUNode(fileType);
604                 this.setCurrentUNode(fileType);
605                 fileType.startElement(namespaceURI, localName, qName, atts);
606                 // Add this value in
607
this.fileType = fileType;
608                 return;
609             }
610             if (localName.equals("FileName") && (fileName==null)) {
611                 FileNameImpl fileName = FileNameImpl.newInstance();
612                 current = getCurrentUNode();
613                 fileName.setParentUNode(current);
614                 fileName.setCurrentUNode(fileName);
615                 this.setCurrentUNode(fileName);
616                 fileName.startElement(namespaceURI, localName, qName, atts);
617                 // Add this value in
618
this.fileName = fileName;
619                 return;
620             }
621             if (localName.equals("AbsolutFileName") && (absolutFileName==null)) {
622                 AbsolutFileNameImpl absolutFileName = AbsolutFileNameImpl.newInstance();
623                 current = getCurrentUNode();
624                 absolutFileName.setParentUNode(current);
625                 absolutFileName.setCurrentUNode(absolutFileName);
626                 this.setCurrentUNode(absolutFileName);
627                 absolutFileName.startElement(namespaceURI, localName, qName, atts);
628                 // Add this value in
629
this.absolutFileName = absolutFileName;
630                 return;
631             }
632             if (localName.equals("AbsolutDirPath") && (absolutDirPath==null)) {
633                 AbsolutDirPathImpl absolutDirPath = AbsolutDirPathImpl.newInstance();
634                 current = getCurrentUNode();
635                 absolutDirPath.setParentUNode(current);
636                 absolutDirPath.setCurrentUNode(absolutDirPath);
637                 this.setCurrentUNode(absolutDirPath);
638                 absolutDirPath.startElement(namespaceURI, localName, qName, atts);
639                 // Add this value in
640
this.absolutDirPath = absolutDirPath;
641                 return;
642             }
643             if (localName.equals("AbsolutFilePath") && (absolutFilePath==null)) {
644                 AbsolutFilePathImpl absolutFilePath = AbsolutFilePathImpl.newInstance();
645                 current = getCurrentUNode();
646                 absolutFilePath.setParentUNode(current);
647                 absolutFilePath.setCurrentUNode(absolutFilePath);
648                 this.setCurrentUNode(absolutFilePath);
649                 absolutFilePath.startElement(namespaceURI, localName, qName, atts);
650                 // Add this value in
651
this.absolutFilePath = absolutFilePath;
652                 return;
653             }
654             if (localName.equals("RelativeDirPath") && (relativeDirPath==null)) {
655                 RelativeDirPathImpl relativeDirPath = RelativeDirPathImpl.newInstance();
656                 current = getCurrentUNode();
657                 relativeDirPath.setParentUNode(current);
658                 relativeDirPath.setCurrentUNode(relativeDirPath);
659                 this.setCurrentUNode(relativeDirPath);
660                 relativeDirPath.startElement(namespaceURI, localName, qName, atts);
661                 // Add this value in
662
this.relativeDirPath = relativeDirPath;
663                 return;
664             }
665             if (localName.equals("RelativeFilePath") && (relativeFilePath==null)) {
666                 RelativeFilePathImpl relativeFilePath = RelativeFilePathImpl.newInstance();
667                 current = getCurrentUNode();
668                 relativeFilePath.setParentUNode(current);
669                 relativeFilePath.setCurrentUNode(relativeFilePath);
670                 this.setCurrentUNode(relativeFilePath);
671                 relativeFilePath.startElement(namespaceURI, localName, qName, atts);
672                 // Add this value in
673
this.relativeFilePath = relativeFilePath;
674                 return;
675             }
676             if (localName.equals("Mapped") && (mapped==null)) {
677                 MappedImpl mapped = MappedImpl.newInstance();
678                 current = getCurrentUNode();
679                 mapped.setParentUNode(current);
680                 mapped.setCurrentUNode(mapped);
681                 this.setCurrentUNode(mapped);
682                 mapped.startElement(namespaceURI, localName, qName, atts);
683                 // Add this value in
684
this.mapped = mapped;
685                 return;
686             }
687             if (localName.equals("GrantedDownload") && (grantedDownload==null)) {
688                 GrantedDownloadImpl grantedDownload = GrantedDownloadImpl.newInstance();
689                 current = getCurrentUNode();
690                 grantedDownload.setParentUNode(current);
691                 grantedDownload.setCurrentUNode(grantedDownload);
692                 this.setCurrentUNode(grantedDownload);
693                 grantedDownload.startElement(namespaceURI, localName, qName, atts);
694                 // Add this value in
695
this.grantedDownload = grantedDownload;
696                 return;
697             }
698             if (localName.equals("Score") && (score==null)) {
699                 ScoreImpl score = ScoreImpl.newInstance();
700                 current = getCurrentUNode();
701                 score.setParentUNode(current);
702                 score.setCurrentUNode(score);
703                 this.setCurrentUNode(score);
704                 score.startElement(namespaceURI, localName, qName, atts);
705                 // Add this value in
706
this.score = score;
707                 return;
708             }
709             if (localName.equals("Modified") && (modified==null)) {
710                 ModifiedImpl modified = ModifiedImpl.newInstance();
711                 current = getCurrentUNode();
712                 modified.setParentUNode(current);
713                 modified.setCurrentUNode(modified);
714                 this.setCurrentUNode(modified);
715                 modified.startElement(namespaceURI, localName, qName, atts);
716                 // Add this value in
717
this.modified = modified;
718                 return;
719             }
720             if (localName.equals("Content") && (content==null)) {
721                 ContentImpl content = ContentImpl.newInstance();
722                 current = getCurrentUNode();
723                 content.setParentUNode(current);
724                 content.setCurrentUNode(content);
725                 this.setCurrentUNode(content);
726                 content.startElement(namespaceURI, localName, qName, atts);
727                 // Add this value in
728
this.content = content;
729                 return;
730             }
731             if (localName.equals("Properties") && (properties==null)) {
732                 PropertiesImpl properties = PropertiesImpl.newInstance();
733                 current = getCurrentUNode();
734                 properties.setParentUNode(current);
735                 properties.setCurrentUNode(properties);
736                 this.setCurrentUNode(properties);
737                 properties.startElement(namespaceURI, localName, qName, atts);
738                 // Add this value in
739
this.properties = properties;
740                 return;
741             }
742             if (localName.equals("MetaData") && (metaData==null)) {
743                 MetaDataImpl metaData = MetaDataImpl.newInstance();
744                 current = getCurrentUNode();
745                 metaData.setParentUNode(current);
746                 metaData.setCurrentUNode(metaData);
747                 this.setCurrentUNode(metaData);
748                 metaData.startElement(namespaceURI, localName, qName, atts);
749                 // Add this value in
750
this.metaData = metaData;
751                 return;
752             }
753         }
754     }
755
756     public void endElement(String JavaDoc namespaceURI, String JavaDoc localName,
757                            String JavaDoc qName)
758         throws SAXException JavaDoc {
759
760         Unmarshallable current = getCurrentUNode();
761         if (current != this) {
762             current.endElement(namespaceURI, localName, qName);
763             return;
764         }
765
766         Unmarshallable parent = getCurrentUNode().getParentUNode();
767         if (parent != null) {
768             parent.setCurrentUNode(parent);
769         }
770     }
771
772     public void characters(char[] ch, int start, int len)
773         throws SAXException JavaDoc {
774
775         // Feed this to the correct ContentHandler
776
Unmarshallable current = getCurrentUNode();
777         if (current != this) {
778             current.characters(ch, start, len);
779             return;
780         }
781
782         String JavaDoc text = new String JavaDoc(ch, start, len);
783     }
784
785     public void comment(char ch[], int start, int len) throws SAXException JavaDoc {
786         // Currently no-op
787
}
788
789     public void warning(SAXParseException JavaDoc e) throws SAXException JavaDoc {
790         if (errorHandler != null) {
791             errorHandler.warning(e);
792         }
793     }
794
795     public void error(SAXParseException JavaDoc e) throws SAXException JavaDoc {
796         if ((validate) && (!hasDTD)) {
797             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.");
798         }
799         if (errorHandler != null) {
800             errorHandler.error(e);
801         }
802     }
803
804     public void fatalError(SAXParseException JavaDoc e) throws SAXException JavaDoc {
805         if ((validate) && (!hasDTD)) {
806             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.");
807         }
808         if (errorHandler != null) {
809             errorHandler.fatalError(e);
810         }
811     }
812
813     public void startDTD(String JavaDoc name, String JavaDoc publicID, String JavaDoc systemID)
814         throws SAXException JavaDoc {
815
816         if ((name == null) || (name.equals(""))) {
817             docTypeString = "";
818             return;
819         }
820
821         hasDTD = true;
822         StringBuffer JavaDoc docTypeSB = new StringBuffer JavaDoc();
823         boolean hasPublic = false;
824
825         docTypeSB.append("<!DOCTYPE ")
826                  .append(name);
827
828         if ((publicID != null) && (!publicID.equals(""))) {
829             docTypeSB.append(" PUBLIC \"")
830                      .append(publicID)
831                      .append("\"");
832             hasPublic = true;
833         }
834
835         if ((systemID != null) && (!systemID.equals(""))) {
836             if (!hasPublic) {
837                 docTypeSB.append(" SYSTEM");
838             }
839             docTypeSB.append(" \"")
840                      .append(systemID)
841                      .append("\"");
842
843         }
844
845         docTypeSB.append(">");
846
847         docTypeString = docTypeSB.toString();
848     }
849
850     public void endDTD() throws SAXException JavaDoc {
851         // Currently no-op
852
}
853
854     public void startEntity(String JavaDoc name) throws SAXException JavaDoc {
855         // Currently no-op
856
}
857
858     public void endEntity(String JavaDoc name) throws SAXException JavaDoc {
859         // Currently no-op
860
}
861
862     public void startCDATA() throws SAXException JavaDoc {
863         // Currently no-op
864
}
865
866     public void endCDATA() throws SAXException JavaDoc {
867         // Currently no-op
868
}
869
870 }
871
Popular Tags