1 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 ; 19 import org.xml.sax.XMLReader ; 20 21 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 xmlReader) { 48 super(xmlReader); 49 this.db = db; 50 } 51 52 public O3SAXReader(OzoneInterface db, XMLReader xmlReader, boolean validating) { 53 super(xmlReader, validating); 54 this.db = db; 55 } 56 57 public O3SAXReader(OzoneInterface db, String xmlReaderClassName) throws SAXException { 58 super(xmlReaderClassName); 59 this.db = db; 60 } 61 62 public O3SAXReader(OzoneInterface db, String xmlReaderClassName, boolean validating) throws SAXException { 63 super(xmlReaderClassName, validating); 64 this.db = db; 65 } 66 67 76 77 public DocumentFactory getDocumentFactory() { 78 throw new OzoneRemoteException("getDocumentFactory will not work in Ozone"); 79 } 80 81 84 protected SAXContentHandler createContentHandler(XMLReader reader) { 85 return new SAXContentHandler( 86 getNodeFactory(), getDispatchHandler() 87 ); 88 } 89 90 public NodeFactory getNodeFactory() { 91 try { 92 return (NodeFactory) db.objectForName(OzoneDocumentFactory.OBJECT_NAME); 95 } catch (Exception e) { 96 throw new OzoneRemoteException("NodeFctory not registered" + e.toString()); 97 } 98 } 99 100 protected XPathFactory getXPathFactory() { 101 try { 102 return (XPathFactory) db.objectForName(OzoneDocumentFactory.OBJECT_NAME); 105 } catch (Exception e) { 106 throw new OzoneRemoteException("XPathFactory not registered" + e.toString()); 107 } 108 } 109 110 } 111 | Popular Tags |