KickJava   Java API By Example, From Geeks To Geeks.

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


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: OzoneCommentImpl.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.OzoneComment;
15 import org.ozoneDB.xml.dom4j.OzoneDocumentFactory;
16
17 /**
18  *
19  * @author Per Nyfelt
20  */

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

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

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