KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom4j > o3impl > OzoneEntityImpl


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: OzoneEntityImpl.java,v 1.1 2003/11/02 18:10:03 per_nyfelt Exp $
8
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 /**
18  *
19  * @author Per Nyfelt
20  */

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 JavaDoc name) {
29         return (OzoneEntity) db.createObject(OzoneEntityImpl.class,
30                 new Class JavaDoc[] {String JavaDoc.class},
31                 new Object JavaDoc[]{name});
32     }
33
34     /** Creates the <code>Entity</code> with the specified name
35      *
36      * @param name is the name of the entity
37      */

38     public OzoneEntityImpl(String JavaDoc name) {
39         super(name);
40         init();
41     }
42
43     public static OzoneEntity create(OzoneInterface db, String JavaDoc name, String JavaDoc text) {
44         final Class JavaDoc[] signature = new Class JavaDoc[] {String JavaDoc.class, String JavaDoc.class};
45         return (OzoneEntity) db.createObject(OzoneEntityImpl.class,
46                 signature,
47                 new Object JavaDoc[]{name, text});
48     }
49
50     /** Creates the <code>Entity</code> with the specified name
51      * and text.
52      *
53      * @param name is the name of the entity
54      * @param text is the text of the entity
55      */

56     public OzoneEntityImpl(String JavaDoc name, String JavaDoc text) {
57         super(name, text);
58         init();
59     }
60
61     public static OzoneEntity create(OzoneInterface db, Element parent, String JavaDoc name, String JavaDoc text) {
62         final Class JavaDoc[] signature = new Class JavaDoc[] {Element.class, String JavaDoc.class, String JavaDoc.class};
63         return (OzoneEntity) db.createObject(OzoneEntityImpl.class,
64                 signature,
65                 new Object JavaDoc[]{parent, name, text});
66     }
67
68     /** Creates the <code>Entity</code> with the specified name
69      * and text.
70      *
71      * @param parent is the parent element
72      * @param name is the name of the entity
73      * @param text is the text of the entity
74      */

75     public OzoneEntityImpl(Element parent, String JavaDoc name, String JavaDoc 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             // todo: might be faster to return super.getNodeFactory() if it is instanceof OzoneCompatible first
87
// before falling back to object for name look-up
88
return (NodeFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME);
89         } catch (Exception JavaDoc e) {
90             throw new OzoneRemoteException("NodeFctory not registered" + e.toString());
91         }
92     }
93
94     protected XPathFactory getXPathFactory() {
95         try {
96             // todo: might be faster to return super.getXPathFactory() if it is instanceof OzoneCompatible first
97
// before falling back to object for name look-up
98
return (XPathFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME);
99         } catch (Exception JavaDoc e) {
100             throw new OzoneRemoteException("XPathFactory not registered" + e.toString());
101         }
102     }
103
104     public Object JavaDoc clone() {
105         try {
106             Node answer = (Node) database().copyObject(self());
107             answer.setDocument(null);
108             answer.setParent(null);
109             return answer;
110         } catch (Exception JavaDoc 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