1 package org.ozoneDB.xml.dom4j.o3impl; 9 10 import org.dom4j.*; 11 import org.ozoneDB.OzoneCompatible; 12 import org.ozoneDB.OzoneInterface; 13 import org.ozoneDB.OzoneRemoteException; 14 import org.ozoneDB.xml.dom4j.OzoneDocumentFactory; 15 import org.ozoneDB.xml.dom4j.OzoneEntity; 16 17 21 public class OzoneEntityImpl extends DefaultEntity implements OzoneEntity, OzoneCompatible { 22 23 final static long serialVersionUID = 1L; 24 25 private void init() { 26 } 27 28 public static OzoneEntity create(OzoneInterface db, String name) { 29 return (OzoneEntity) db.createObject(OzoneEntityImpl.class, 30 new Class [] {String .class}, 31 new Object []{name}); 32 } 33 34 38 public OzoneEntityImpl(String name) { 39 super(name); 40 init(); 41 } 42 43 public static OzoneEntity create(OzoneInterface db, String name, String text) { 44 final Class [] signature = new Class [] {String .class, String .class}; 45 return (OzoneEntity) db.createObject(OzoneEntityImpl.class, 46 signature, 47 new Object []{name, text}); 48 } 49 50 56 public OzoneEntityImpl(String name, String text) { 57 super(name, text); 58 init(); 59 } 60 61 public static OzoneEntity create(OzoneInterface db, Element parent, String name, String text) { 62 final Class [] signature = new Class [] {Element.class, String .class, String .class}; 63 return (OzoneEntity) db.createObject(OzoneEntityImpl.class, 64 signature, 65 new Object []{parent, name, text}); 66 } 67 68 75 public OzoneEntityImpl(Element parent, String name, String text) { 76 super(parent, name, text); 77 init(); 78 } 79 80 public DocumentFactory getDocumentFactory() { 81 throw new OzoneRemoteException("getDocumentFactory will not work in Ozone"); 82 } 83 84 protected NodeFactory getNodeFactory() { 85 try { 86 return (NodeFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME); 89 } catch (Exception e) { 90 throw new OzoneRemoteException("NodeFctory not registered" + e.toString()); 91 } 92 } 93 94 protected XPathFactory getXPathFactory() { 95 try { 96 return (XPathFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME); 99 } catch (Exception e) { 100 throw new OzoneRemoteException("XPathFactory not registered" + e.toString()); 101 } 102 } 103 104 public Object clone() { 105 try { 106 Node answer = (Node) database().copyObject(self()); 107 answer.setDocument(null); 108 answer.setParent(null); 109 return answer; 110 } catch (Exception e) { 111 e.printStackTrace(); 112 return null; 113 } 114 } 115 116 public void onCreate() { 117 } 118 119 public void onActivate() { 120 } 121 122 public void onPassivate() { 123 } 124 125 public void onDelete() { 126 } 127 } 128 | Popular Tags |