KickJava   Java API By Example, From Geeks To Geeks.

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


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: OzoneTextImpl.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.OzoneText;
16
17 /**
18  *
19  * @author Per Nyfelt
20  */

21 public class OzoneTextImpl extends DefaultText implements OzoneText, OzoneCompatible {
22
23     final static long serialVersionUID = 1L;
24
25     private void init() {
26     }
27
28     public static OzoneText create(OzoneInterface db, String JavaDoc text) {
29         return (OzoneText) db.createObject(OzoneTextImpl.class,
30                 new Class JavaDoc[] {String JavaDoc.class},
31                 new Object JavaDoc[]{text});
32     }
33
34     /** @param text is the Text text
35      */

36     public OzoneTextImpl(String JavaDoc text) {
37         super(text);
38         init();
39     }
40
41     public static OzoneText create(OzoneInterface db, Element parent, String JavaDoc text) {
42         final Class JavaDoc[] signature = new Class JavaDoc[] {Element.class, String JavaDoc.class};
43         return (OzoneText) db.createObject(OzoneTextImpl.class,
44                 signature,
45                 new Object JavaDoc[]{parent, text});
46     }
47
48     /** @param parent is the parent element
49      * @param text is the Text text
50      */

51     public OzoneTextImpl(Element parent, String JavaDoc text) {
52         super(parent, text);
53         init();
54     }
55
56     public DocumentFactory getDocumentFactory() {
57         throw new OzoneRemoteException("getDocumentFactory will not work in Ozone");
58     }
59
60     protected NodeFactory getNodeFactory() {
61         try {
62             // todo: might be faster to return super.getNodeFactory() if it is instanceof OzoneCompatible first
63
// before falling back to object for name look-up
64
return (NodeFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME);
65         } catch (Exception JavaDoc e) {
66             throw new OzoneRemoteException("NodeFctory not registered" + e.toString());
67         }
68     }
69
70     protected XPathFactory getXPathFactory() {
71         try {
72             // todo: might be faster to return super.getXPathFactory() if it is instanceof OzoneCompatible first
73
// before falling back to object for name look-up
74
return (XPathFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME);
75         } catch (Exception JavaDoc e) {
76             throw new OzoneRemoteException("XPathFactory not registered" + e.toString());
77         }
78     }
79
80     public Object JavaDoc clone() {
81         try {
82             Node answer = (Node) database().copyObject(self());
83             answer.setDocument(null);
84             answer.setParent(null);
85             return answer;
86         } catch (Exception JavaDoc e) {
87             e.printStackTrace();
88             return null;
89         }
90     }
91
92     public void onCreate() {
93     }
94
95     public void onActivate() {
96     }
97
98     public void onPassivate() {
99     }
100
101     public void onDelete() {
102     }
103 }
104
Popular Tags