KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom4j > io > O3SAXReader


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: O3SAXReader.java,v 1.1 2003/07/12 12:13:06 per_nyfelt Exp $
8
package org.ozoneDB.xml.dom4j.io;
9
10 import org.dom4j.DocumentFactory;
11 import org.dom4j.NodeFactory;
12 import org.dom4j.XPathFactory;
13 import org.dom4j.io.SAXContentHandler;
14 import org.dom4j.io.SAXReader;
15 import org.ozoneDB.OzoneInterface;
16 import org.ozoneDB.OzoneRemoteException;
17 import org.ozoneDB.xml.dom4j.OzoneDocumentFactory;
18 import org.xml.sax.SAXException JavaDoc;
19 import org.xml.sax.XMLReader JavaDoc;
20
21 /**
22  * $Id: O3SAXReader.java,v 1.1 2003/07/12 12:13:06 per_nyfelt Exp $
23  */

24 public class O3SAXReader extends SAXReader {
25
26     OzoneInterface db;
27
28     public O3SAXReader(OzoneInterface db) {
29         this.db = db;
30     }
31
32     public O3SAXReader(OzoneInterface db, boolean validating) {
33         super(validating);
34         this.db = db;
35     }
36
37     public O3SAXReader(OzoneInterface db, OzoneDocumentFactory factory) {
38         super(factory);
39         this.db = db;
40     }
41
42     public O3SAXReader(OzoneInterface db, DocumentFactory factory, boolean validating) {
43         super(factory, validating);
44         this.db = db;
45     }
46
47     public O3SAXReader(OzoneInterface db, XMLReader JavaDoc xmlReader) {
48         super(xmlReader);
49         this.db = db;
50     }
51
52     public O3SAXReader(OzoneInterface db, XMLReader JavaDoc xmlReader, boolean validating) {
53         super(xmlReader, validating);
54         this.db = db;
55     }
56
57     public O3SAXReader(OzoneInterface db, String JavaDoc xmlReaderClassName) throws SAXException JavaDoc {
58         super(xmlReaderClassName);
59         this.db = db;
60     }
61
62     public O3SAXReader(OzoneInterface db, String JavaDoc xmlReaderClassName, boolean validating) throws SAXException JavaDoc {
63         super(xmlReaderClassName, validating);
64         this.db = db;
65     }
66
67 /* public DocumentFactory getDocumentFactory() {
68         try {
69             System.out.println("[O3SAXReader] getting factory for db " + db);
70             return OzoneDocumentFactoryImpl.getInstance(db);
71         } catch (Exception e) {
72             e.printStackTrace();
73             throw new OzoneRemoteException("Documentfactory not registered" + e.toString());
74         }
75     }*/

76
77     public DocumentFactory getDocumentFactory() {
78         throw new OzoneRemoteException("getDocumentFactory will not work in Ozone");
79     }
80
81     /** Factory Method to allow user derived SAXContentHandler objects to be used
82      * overridden since the super class is still using the deprecated getDocumentFactory()
83      */

84     protected SAXContentHandler createContentHandler(XMLReader JavaDoc reader) {
85         return new SAXContentHandler(
86                 getNodeFactory(), getDispatchHandler()
87         );
88     }
89
90     public NodeFactory getNodeFactory() {
91         try {
92             // todo: might be faster to return super.getNodeFactory() if it is instanceof OzoneCompatible first
93
// before falling back to object for name look-up
94
return (NodeFactory) db.objectForName(OzoneDocumentFactory.OBJECT_NAME);
95         } catch (Exception JavaDoc e) {
96             throw new OzoneRemoteException("NodeFctory not registered" + e.toString());
97         }
98     }
99
100     protected XPathFactory getXPathFactory() {
101         try {
102             // todo: might be faster to return super.getXPathFactory() if it is instanceof OzoneCompatible first
103
// before falling back to object for name look-up
104
return (XPathFactory) db.objectForName(OzoneDocumentFactory.OBJECT_NAME);
105         } catch (Exception JavaDoc e) {
106             throw new OzoneRemoteException("XPathFactory not registered" + e.toString());
107         }
108     }
109
110 }
111
Popular Tags