KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > AbstractDocument


1 /*
2
3    Copyright 2000-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom;
19
20 import java.io.IOException JavaDoc;
21 import java.io.ObjectInputStream JavaDoc;
22 import java.io.ObjectOutputStream JavaDoc;
23 import java.lang.reflect.Method JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.HashMap JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Locale JavaDoc;
29 import java.util.Map JavaDoc;
30 import java.util.MissingResourceException JavaDoc;
31 import java.util.WeakHashMap JavaDoc;
32
33 import org.apache.batik.dom.events.DocumentEventSupport;
34 import org.apache.batik.dom.traversal.TraversalSupport;
35 import org.apache.batik.i18n.Localizable;
36 import org.apache.batik.i18n.LocalizableSupport;
37 import org.apache.batik.util.CleanerThread;
38 import org.apache.batik.util.SoftDoublyIndexedTable;
39 import org.w3c.dom.Attr JavaDoc;
40 import org.w3c.dom.DOMException JavaDoc;
41 import org.w3c.dom.DOMImplementation JavaDoc;
42 import org.w3c.dom.Document JavaDoc;
43 import org.w3c.dom.DocumentType JavaDoc;
44 import org.w3c.dom.Element JavaDoc;
45 import org.w3c.dom.NamedNodeMap JavaDoc;
46 import org.w3c.dom.Node JavaDoc;
47 import org.w3c.dom.events.DocumentEvent JavaDoc;
48 import org.w3c.dom.events.Event JavaDoc;
49 import org.w3c.dom.traversal.DocumentTraversal;
50 import org.w3c.dom.traversal.NodeFilter;
51 import org.w3c.dom.traversal.NodeIterator;
52 import org.w3c.dom.traversal.TreeWalker;
53
54 /**
55  * This class implements the {@link org.w3c.dom.Document} interface.
56  *
57  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
58  * @version $Id: AbstractDocument.java,v 1.27 2005/03/03 01:19:53 deweese Exp $
59  */

60 public abstract class AbstractDocument
61     extends AbstractParentNode
62     implements Document JavaDoc,
63                DocumentEvent JavaDoc,
64                DocumentTraversal,
65                Localizable {
66
67     /**
68      * The error messages bundle class name.
69      */

70     protected final static String JavaDoc RESOURCES =
71         "org.apache.batik.dom.resources.Messages";
72
73     /**
74      * The localizable support for the error messages.
75      */

76     protected transient LocalizableSupport localizableSupport =
77         new LocalizableSupport
78         (RESOURCES, getClass().getClassLoader());
79
80     /**
81      * The DOM implementation.
82      */

83     protected transient DOMImplementation JavaDoc implementation;
84
85     /**
86      * The traversal support.
87      */

88     protected transient TraversalSupport traversalSupport;
89
90     /**
91      * The DocumentEventSupport.
92      */

93     protected transient DocumentEventSupport documentEventSupport;
94
95     /**
96      * Whether the event dispatching must be done.
97      */

98     protected transient boolean eventsEnabled;
99
100     /**
101      * The ElementsByTagName lists.
102      */

103     protected transient WeakHashMap JavaDoc elementsByTagNames;
104
105     /**
106      * The ElementsByTagNameNS lists.
107      */

108     protected transient WeakHashMap JavaDoc elementsByTagNamesNS;
109
110     /**
111      * The elementsById lists.
112      * This is keyed on 'id'. the entry is either
113      * a IdSoftReference to the element or a List of
114      * IdSoftReferences (if there is more than one element
115      * owned by this document with a particular 'id').
116      */

117     protected transient Map JavaDoc elementsById;
118
119     /**
120      * Creates a new document.
121      */

122     protected AbstractDocument() {
123     }
124
125     /**
126      * Creates a new document.
127      */

128     public AbstractDocument(DocumentType JavaDoc dt, DOMImplementation JavaDoc impl) {
129     implementation = impl;
130         if (dt != null) {
131             if (dt instanceof GenericDocumentType) {
132                 GenericDocumentType gdt = (GenericDocumentType)dt;
133                 if (gdt.getOwnerDocument() == null)
134                     gdt.setOwnerDocument(this);
135             }
136             appendChild(dt);
137         }
138     }
139
140     /**
141      * Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.
142      */

143     public void setLocale(Locale JavaDoc l) {
144     localizableSupport.setLocale(l);
145     }
146
147     /**
148      * Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.
149      */

150     public Locale JavaDoc getLocale() {
151         return localizableSupport.getLocale();
152     }
153
154     /**
155      * Implements {@link
156      * org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.
157      */

158     public String JavaDoc formatMessage(String JavaDoc key, Object JavaDoc[] args)
159         throws MissingResourceException JavaDoc {
160         return localizableSupport.formatMessage(key, args);
161     }
162
163     /**
164      * Tests whether the event dispatching must be done.
165      */

166     public boolean getEventsEnabled() {
167     return eventsEnabled;
168     }
169
170     /**
171      * Sets the eventsEnabled property.
172      */

173     public void setEventsEnabled(boolean b) {
174     eventsEnabled = b;
175     }
176
177     /**
178      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeName()}.
179      * @return "#document".
180      */

181     public String JavaDoc getNodeName() {
182     return "#document";
183     }
184
185     /**
186      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeType()}.
187      * @return {@link org.w3c.dom.Node#DOCUMENT_NODE}
188      */

189     public short getNodeType() {
190     return DOCUMENT_NODE;
191     }
192
193     /**
194      * <b>DOM</b>: Implements {@link org.w3c.dom.Document#getDoctype()}.
195      */

196     public DocumentType JavaDoc getDoctype() {
197     for (Node JavaDoc n = getFirstChild(); n != null; n = n.getNextSibling()) {
198         if (n.getNodeType() == DOCUMENT_TYPE_NODE) {
199         return (DocumentType JavaDoc)n;
200         }
201     }
202     return null;
203     }
204
205     /**
206      * Sets the document type node.
207      */

208     public void setDoctype(DocumentType JavaDoc dt) {
209     if (dt != null) {
210         appendChild(dt);
211         ((ExtendedNode)dt).setReadonly(true);
212     }
213     }
214
215     /**
216      * <b>DOM</b>: Implements {@link org.w3c.dom.Document#getImplementation()}.
217      * @return {@link #implementation}
218      */

219     public DOMImplementation JavaDoc getImplementation() {
220     return implementation;
221     }
222
223     /**
224      * <b>DOM</b>: Implements {@link
225      * org.w3c.dom.Document#getDocumentElement()}.
226      */

227     public Element JavaDoc getDocumentElement() {
228     for (Node JavaDoc n = getFirstChild(); n != null; n = n.getNextSibling()) {
229         if (n.getNodeType() == ELEMENT_NODE) {
230         return (Element JavaDoc)n;
231         }
232     }
233     return null;
234     }
235
236     /**
237      * <b>DOM</b>: Implements {@link
238      * org.w3c.dom.Document#importNode(Node,boolean)}.
239      */

240     public Node JavaDoc importNode(Node JavaDoc importedNode, boolean deep)
241         throws DOMException JavaDoc {
242         return importNode(importedNode, deep, false);
243     }
244
245     /**
246      * Imports the given node 'importNode' to this document.
247      * It does so deeply if 'deep' is set to true.
248      * It will not mark id attributes as id's if 'trimId' is set false.
249      * this is used primarily for the clone trees of the 'use' element
250      * so they don't clutter the hashtable.
251      */

252     public Node JavaDoc importNode(Node JavaDoc importedNode, boolean deep, boolean trimId) {
253         /*
254          * The trimming of id's is used by the 'use' element to keep
255          * down the amount of 'bogus' id's in the hashtable.
256          */

257         Node JavaDoc result;
258         switch (importedNode.getNodeType()) {
259         case ELEMENT_NODE:
260             Element JavaDoc e = createElementNS(importedNode.getNamespaceURI(),
261                                         importedNode.getNodeName());
262             result = e;
263             if (importedNode.hasAttributes()) {
264                 NamedNodeMap JavaDoc attr = importedNode.getAttributes();
265                 int len = attr.getLength();
266                 for (int i = 0; i < len; i++) {
267                     Attr JavaDoc a = (Attr JavaDoc)attr.item(i);
268                     if (!a.getSpecified()) continue;
269                     AbstractAttr aa = (AbstractAttr)importNode(a, true);
270                     if (trimId && aa.isId())
271                         aa.setIsId(false); // don't consider this an Id.
272
e.setAttributeNodeNS(aa);
273                 }
274             }
275             break;
276             
277         case ATTRIBUTE_NODE:
278             result = createAttributeNS(importedNode.getNamespaceURI(),
279                                        importedNode.getNodeName());
280             break;
281             
282         case TEXT_NODE:
283             result = createTextNode(importedNode.getNodeValue());
284             deep = false;
285             break;
286             
287         case CDATA_SECTION_NODE:
288             result = createCDATASection(importedNode.getNodeValue());
289             deep = false;
290             break;
291             
292         case ENTITY_REFERENCE_NODE:
293             result = createEntityReference(importedNode.getNodeName());
294             break;
295             
296         case PROCESSING_INSTRUCTION_NODE:
297             result = createProcessingInstruction
298                 (importedNode.getNodeName(),
299                  importedNode.getNodeValue());
300             deep = false;
301             break;
302             
303         case COMMENT_NODE:
304             result = createComment(importedNode.getNodeValue());
305             deep = false;
306             break;
307             
308         case DOCUMENT_FRAGMENT_NODE:
309             result = createDocumentFragment();
310             break;
311
312         default:
313             throw createDOMException(DOMException.NOT_SUPPORTED_ERR,
314                                      "import.node",
315                                      new Object JavaDoc[] {});
316         }
317         
318         if (deep) {
319             for (Node JavaDoc n = importedNode.getFirstChild();
320                  n != null;
321                  n = n.getNextSibling()) {
322                 result.appendChild(importNode(n, true));
323             }
324         }
325         return result;
326     }
327
328     /**
329      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#cloneNode(boolean)}.
330      */

331     public Node JavaDoc cloneNode(boolean deep) {
332         Document JavaDoc n = (Document JavaDoc)newNode();
333         copyInto(n);
334         if (deep) {
335             for (Node JavaDoc c = getFirstChild();
336                  c != null;
337                  c = c.getNextSibling()) {
338                 n.appendChild(n.importNode(c, deep));
339             }
340         }
341         return n;
342     }
343
344     public abstract boolean isId(Attr JavaDoc node);
345
346     /**
347      * <b>DOM</b>: Implements {@link
348      * org.w3c.dom.Document#getElementById(String)}.
349      */

350     public Element JavaDoc getElementById(String JavaDoc id) {
351         return getChildElementById(getDocumentElement(), id);
352     }
353
354     /**
355      * Finds an element that is in the same document fragment as
356      * 'requestor' that has 'id'.
357      */

358     public Element JavaDoc getChildElementById(Node JavaDoc requestor, String JavaDoc id) {
359         if ((id == null) || (id.length()==0)) return null;
360         if (elementsById == null) return null;
361
362         Node JavaDoc root = getRoot(requestor);
363
364         Object JavaDoc o = elementsById.get(id);
365         if (o == null) return null;
366         if (o instanceof IdSoftRef) {
367             o = ((IdSoftRef)o).get();
368             if (o == null) {
369                 elementsById.remove(id);
370                 return null;
371             }
372             Element JavaDoc e = (Element JavaDoc)o;
373             if (getRoot(e) == root)
374                 return e;
375             return null;
376         }
377         
378         // Not a IdSoftRef so it must be a list.
379
List JavaDoc l = (List JavaDoc)o;
380         Iterator JavaDoc li = l.iterator();
381         while (li.hasNext()) {
382             IdSoftRef sr = (IdSoftRef)li.next();
383             o = sr.get();
384             if (o == null) {
385                 li.remove();
386             } else {
387                 Element JavaDoc e = (Element JavaDoc)o;
388                 if (getRoot(e) == root)
389                     return e;
390             }
391         }
392         return null;
393     }
394
395     protected Node JavaDoc getRoot(Node JavaDoc n) {
396         Node JavaDoc r = n;
397         while (n != null) {
398             r = n;
399             n = n.getParentNode();
400         }
401         return r;
402     }
403
404     protected class IdSoftRef extends CleanerThread.SoftReferenceCleared {
405         String JavaDoc id;
406         List JavaDoc list;
407         IdSoftRef(Object JavaDoc o, String JavaDoc id) {
408             super(o);
409             this.id = id;
410         }
411         IdSoftRef(Object JavaDoc o, String JavaDoc id, List JavaDoc list) {
412             super(o);
413             this.id = id;
414             this.list = list;
415         }
416         public void setList(List JavaDoc list) {
417             this.list = list;
418         }
419         public void cleared() {
420             if (elementsById == null) return;
421             synchronized (elementsById) {
422                 if (list != null)
423                     list.remove(this);
424                 else {
425                   Object JavaDoc o = elementsById.remove(id);
426                   if (o != this) // oops not us!
427
elementsById.put(id, o);
428                 }
429             }
430         }
431     }
432
433     /**
434      * Remove the mapping for <tt>element</tt> to <tt>id</tt>
435      */

436     public void removeIdEntry(Element JavaDoc e, String JavaDoc id) {
437         // Remove old Id mapping if we have one.
438
if (id == null) return;
439         if (elementsById == null) return;
440
441         synchronized (elementsById) {
442             Object JavaDoc o = elementsById.get(id);
443             if (o == null) return;
444
445             if (o instanceof IdSoftRef) {
446                 elementsById.remove(id);
447                 return;
448             }
449             
450             List JavaDoc l = (List JavaDoc)o;
451             Iterator JavaDoc li = l.iterator();
452             while (li.hasNext()) {
453                 IdSoftRef ip = (IdSoftRef)li.next();
454                 o = ip.get();
455                 if (o == null) {
456                     li.remove();
457                 } else if (e == o) {
458                     li.remove();
459                     break;
460                 }
461             }
462             
463             if (l.size() == 0)
464                 elementsById.remove(id);
465         }
466     }
467
468     public void addIdEntry(Element JavaDoc e, String JavaDoc id) {
469         if (id == null) return;
470
471         if (elementsById == null) {
472             Map JavaDoc tmp = new HashMap JavaDoc();
473             synchronized (tmp) {
474                 elementsById = tmp;
475                 elementsById.put(id, new IdSoftRef(e, id));
476             }
477             return;
478         }
479
480         synchronized (elementsById) {
481             // Add new Id mapping.
482
Object JavaDoc o = elementsById.get(id);
483             if (o == null) {
484                 elementsById.put(id, new IdSoftRef(e, id));
485                 return;
486             }
487             if (o instanceof IdSoftRef) {
488                 IdSoftRef ip = (IdSoftRef)o;
489                 Object JavaDoc r = ip.get();
490                 if (r == null) { // reference is gone so replace it.
491
elementsById.put(id, new IdSoftRef(e, id));
492                     return;
493                 }
494                 
495                 // Create new List for this id.
496
List JavaDoc l = new ArrayList JavaDoc(4);
497                 ip.setList(l);
498                 l.add(ip);
499                 l.add(new IdSoftRef(e, id, l));
500                 elementsById.put(id, l);
501                 return;
502             }
503             
504             List JavaDoc l = (List JavaDoc)o;
505             l.add(new IdSoftRef(e, id, l));
506         }
507     }
508
509     public void updateIdEntry(Element JavaDoc e, String JavaDoc oldId, String JavaDoc newId) {
510         if ((oldId == newId) ||
511             ((oldId != null) && (oldId.equals(newId))))
512             return;
513
514         removeIdEntry(e, oldId);
515
516         addIdEntry(e, newId);
517     }
518
519
520     /**
521      * Returns an ElementsByTagName object from the cache, if any.
522      */

523     public ElementsByTagName getElementsByTagName(Node JavaDoc n, String JavaDoc ln) {
524         if (elementsByTagNames == null) {
525             return null;
526         }
527         SoftDoublyIndexedTable t;
528         t = (SoftDoublyIndexedTable)elementsByTagNames.get(n);
529         if (t == null) {
530             return null;
531         }
532         return (ElementsByTagName)t.get(null, ln);
533     }
534
535     /**
536      * Puts an ElementsByTagName object in the cache.
537      */

538     public void putElementsByTagName(Node JavaDoc n, String JavaDoc ln, ElementsByTagName l) {
539         if (elementsByTagNames == null) {
540             elementsByTagNames = new WeakHashMap JavaDoc(11);
541         }
542         SoftDoublyIndexedTable t;
543         t = (SoftDoublyIndexedTable)elementsByTagNames.get(n);
544         if (t == null) {
545             elementsByTagNames.put(n, t = new SoftDoublyIndexedTable());
546         }
547         t.put(null, ln, l);
548     }
549
550     /**
551      * Returns an ElementsByTagNameNS object from the cache, if any.
552      */

553     public ElementsByTagNameNS getElementsByTagNameNS(Node JavaDoc n,
554                                                     String JavaDoc ns,
555                                                     String JavaDoc ln) {
556         if (elementsByTagNamesNS == null) {
557             return null;
558         }
559         SoftDoublyIndexedTable t;
560         t = (SoftDoublyIndexedTable)elementsByTagNamesNS.get(n);
561         if (t == null) {
562             return null;
563         }
564         return (ElementsByTagNameNS)t.get(ns, ln);
565     }
566
567     /**
568      * Puts an ElementsByTagNameNS object in the cache.
569      */

570     public void putElementsByTagNameNS(Node JavaDoc n, String JavaDoc ns, String JavaDoc ln,
571                                        ElementsByTagNameNS l) {
572         if (elementsByTagNamesNS == null) {
573             elementsByTagNamesNS = new WeakHashMap JavaDoc(11);
574         }
575         SoftDoublyIndexedTable t;
576         t = (SoftDoublyIndexedTable)elementsByTagNamesNS.get(n);
577         if (t == null) {
578             elementsByTagNamesNS.put(n, t = new SoftDoublyIndexedTable());
579         }
580         t.put(ns, ln, l);
581     }
582
583     // DocumentEvent /////////////////////////////////////////////////////////
584

585     /**
586      * <b>DOM</b>: Implements {@link
587      * org.w3c.dom.events.DocumentEvent#createEvent(String)}.
588      */

589     public Event JavaDoc createEvent(String JavaDoc eventType) throws DOMException JavaDoc {
590         if (documentEventSupport == null) {
591             documentEventSupport =
592                 ((AbstractDOMImplementation)implementation).
593                     createDocumentEventSupport();
594         }
595     return documentEventSupport.createEvent(eventType);
596     }
597
598     // DocumentTraversal /////////////////////////////////////////////////////
599

600     /**
601      * <b>DOM</b>: Implements {@link
602      * DocumentTraversal#createNodeIterator(Node,int,NodeFilter,boolean)}.
603      */

604     public NodeIterator createNodeIterator(Node JavaDoc root,
605                                            int whatToShow,
606                                            NodeFilter filter,
607                                            boolean entityReferenceExpansion)
608         throws DOMException JavaDoc {
609         if (traversalSupport == null) {
610             traversalSupport = new TraversalSupport();
611         }
612         return traversalSupport.createNodeIterator(this, root, whatToShow,
613                                                    filter,
614                                                    entityReferenceExpansion);
615     }
616
617     /**
618      * <b>DOM</b>: Implements {@link
619      * DocumentTraversal#createTreeWalker(Node,int,NodeFilter,boolean)}.
620      */

621     public TreeWalker createTreeWalker(Node JavaDoc root,
622                                        int whatToShow,
623                                        NodeFilter filter,
624                                        boolean entityReferenceExpansion)
625         throws DOMException JavaDoc {
626         return TraversalSupport.createTreeWalker(this, root, whatToShow,
627                                                  filter,
628                                                  entityReferenceExpansion);
629     }
630
631     /**
632      * Detaches the given node iterator from this document.
633      */

634     public void detachNodeIterator(NodeIterator it) {
635         traversalSupport.detachNodeIterator(it);
636     }
637
638     /**
639      * Notifies this document that a node will be removed.
640      */

641     public void nodeToBeRemoved(Node JavaDoc node) {
642         if (traversalSupport != null) {
643             traversalSupport.nodeToBeRemoved(node);
644         }
645     }
646
647     /**
648      * Returns the current document.
649      */

650     protected AbstractDocument getCurrentDocument() {
651     return this;
652     }
653
654     /**
655      * Exports this node to the given document.
656      * @param n The clone node.
657      * @param d The destination document.
658      */

659     protected Node JavaDoc export(Node JavaDoc n, Document JavaDoc d) {
660     throw createDOMException(DOMException.NOT_SUPPORTED_ERR,
661                  "import.document",
662                  new Object JavaDoc[] {});
663     }
664
665     /**
666      * Deeply exports this node to the given document.
667      * @param n The clone node.
668      * @param d The destination document.
669      */

670     protected Node JavaDoc deepExport(Node JavaDoc n, Document JavaDoc d) {
671     throw createDOMException(DOMException.NOT_SUPPORTED_ERR,
672                  "import.document",
673                  new Object JavaDoc[] {});
674     }
675
676     /**
677      * Copy the fields of the current node into the given node.
678      * @param n a node of the type of this.
679      */

680     protected Node JavaDoc copyInto(Node JavaDoc n) {
681     super.copyInto(n);
682     AbstractDocument ad = (AbstractDocument)n;
683     ad.implementation = implementation;
684         ad.localizableSupport = new LocalizableSupport
685             (RESOURCES, getClass().getClassLoader());
686     return n;
687     }
688
689     /**
690      * Deeply copy the fields of the current node into the given node.
691      * @param n a node of the type of this.
692      */

693     protected Node JavaDoc deepCopyInto(Node JavaDoc n) {
694     super.deepCopyInto(n);
695     AbstractDocument ad = (AbstractDocument)n;
696     ad.implementation = implementation;
697         ad.localizableSupport = new LocalizableSupport
698             (RESOURCES, getClass().getClassLoader());
699     return n;
700     }
701
702     /**
703      * Checks the validity of a node to be inserted.
704      */

705     protected void checkChildType(Node JavaDoc n, boolean replace) {
706     short t = n.getNodeType();
707     switch (t) {
708     case ELEMENT_NODE:
709     case PROCESSING_INSTRUCTION_NODE:
710     case COMMENT_NODE:
711     case DOCUMENT_TYPE_NODE:
712     case DOCUMENT_FRAGMENT_NODE:
713         break;
714     default:
715         throw createDOMException(DOMException.HIERARCHY_REQUEST_ERR,
716                      "child.type",
717                      new Object JavaDoc[] { new Integer JavaDoc(getNodeType()),
718                             getNodeName(),
719                                             new Integer JavaDoc(t),
720                             n.getNodeName() });
721     }
722     if (!replace &&
723             (t == ELEMENT_NODE && getDocumentElement() != null) ||
724         (t == DOCUMENT_TYPE_NODE && getDoctype() != null)) {
725         throw createDOMException(DOMException.HIERARCHY_REQUEST_ERR,
726                      "child.type",
727                      new Object JavaDoc[] { new Integer JavaDoc(getNodeType()),
728                             getNodeName(),
729                                             new Integer JavaDoc(t),
730                             n.getNodeName() });
731     }
732     }
733
734     // Serializable /////////////////////////////////////////////////
735

736     private void writeObject(ObjectOutputStream JavaDoc s) throws IOException JavaDoc {
737         s.defaultWriteObject();
738
739         s.writeObject(implementation.getClass().getName());
740     }
741
742     private void readObject(ObjectInputStream JavaDoc s)
743         throws IOException JavaDoc, ClassNotFoundException JavaDoc {
744         s.defaultReadObject();
745
746         localizableSupport = new LocalizableSupport
747             (RESOURCES, getClass().getClassLoader());
748
749         Class JavaDoc c = Class.forName((String JavaDoc)s.readObject());
750
751         try {
752             Method JavaDoc m = c.getMethod("getDOMImplementation", null);
753             implementation = (DOMImplementation JavaDoc)m.invoke(null, null);
754         } catch (Exception JavaDoc e) {
755             try {
756                 implementation = (DOMImplementation JavaDoc)c.newInstance();
757             } catch (Exception JavaDoc ex) {
758             }
759         }
760     }
761 }
762
Popular Tags