KickJava   Java API By Example, From Geeks To Geeks.

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


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: OzoneDocumentTypeImpl.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.DocumentFactory;
11 import org.dom4j.Node;
12 import org.dom4j.NodeFactory;
13 import org.dom4j.XPathFactory;
14 import org.ozoneDB.OzoneCompatible;
15 import org.ozoneDB.OzoneInterface;
16 import org.ozoneDB.OzoneRemoteException;
17 import org.ozoneDB.xml.dom4j.OzoneDocumentFactory;
18 import org.ozoneDB.xml.dom4j.OzoneDocumentType;
19
20 /**
21  *
22  * @author Per Nyfelt
23  */

24 public class OzoneDocumentTypeImpl extends DefaultDocumentType implements OzoneDocumentType, OzoneCompatible {
25
26     final static long serialVersionUID = 1L;
27
28     private void init() {
29     }
30
31     public OzoneDocumentTypeImpl() {
32         init();
33     }
34
35     public static OzoneDocumentType create(OzoneInterface db) {
36         return (OzoneDocumentType) db.createObject(OzoneDocumentTypeImpl.class);
37     }
38
39     /** <p>This will create a new <code>DocumentType</code>
40      * with a reference to the external DTD</p>
41      *
42      * @param elementName is the root element name of the document type
43      * @param systemID is the system ID of the external DTD
44      */

45     public OzoneDocumentTypeImpl(String JavaDoc elementName, String JavaDoc systemID) {
46         super(elementName, systemID);
47         init();
48     }
49
50     public static OzoneDocumentType create(OzoneInterface db, String JavaDoc elementName, String JavaDoc systemID) {
51         final Class JavaDoc[] signature = new Class JavaDoc[] {String JavaDoc.class, String JavaDoc.class};
52         return (OzoneDocumentType) db.createObject(OzoneAttributeImpl.class,
53                 signature,
54                 new Object JavaDoc[]{elementName, systemID});
55     }
56
57     /** <p>This will create a new <code>DocumentType</code>
58      * with a reference to the external DTD</p>
59      *
60      * @param elementName is the root element name of the document type
61      * @param publicID is the public ID of the DTD
62      * @param systemID is the system ID of the DTD
63      */

64     public OzoneDocumentTypeImpl(String JavaDoc elementName, String JavaDoc publicID, String JavaDoc systemID) {
65         super(elementName, publicID, systemID);
66         init();
67     }
68
69     public static OzoneDocumentType create(OzoneInterface db, String JavaDoc elementName, String JavaDoc publicID, String JavaDoc systemID) {
70         final Class JavaDoc[] signature = new Class JavaDoc[] {String JavaDoc.class, String JavaDoc.class, String JavaDoc.class};
71         return (OzoneDocumentType) db.createObject(OzoneAttributeImpl.class,
72                 signature,
73                 new Object JavaDoc[]{elementName, publicID, systemID});
74     }
75
76     public DocumentFactory getDocumentFactory() {
77         throw new OzoneRemoteException("getDocumentFactory will not work in Ozone");
78     }
79
80     protected NodeFactory getNodeFactory() {
81         try {
82             // todo: might be faster to return super.getNodeFactory() if it is instanceof OzoneCompatible first
83
// before falling back to object for name look-up
84
return (NodeFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME);
85         } catch (Exception JavaDoc e) {
86             throw new OzoneRemoteException("NodeFctory not registered" + e.toString());
87         }
88     }
89
90     protected XPathFactory getXPathFactory() {
91         try {
92             // todo: might be faster to return super.getXPathFactory() if it is instanceof OzoneCompatible first
93
// before falling back to object for name look-up
94
return (XPathFactory) database().objectForName(OzoneDocumentFactory.OBJECT_NAME);
95         } catch (Exception JavaDoc e) {
96             throw new OzoneRemoteException("XPathFactory not registered" + e.toString());
97         }
98     }
99
100     public Object JavaDoc clone() {
101         try {
102             Node answer = (Node) database().copyObject(self());
103             answer.setDocument(null);
104             answer.setParent(null);
105             return answer;
106         } catch (Exception JavaDoc e) {
107             e.printStackTrace();
108             return null;
109         }
110     }
111
112     public void onCreate() {
113     }
114
115     public void onActivate() {
116     }
117
118     public void onPassivate() {
119     }
120
121     public void onDelete() {
122     }
123 }
124
Popular Tags