KickJava   Java API By Example, From Geeks To Geeks.

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


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: OzoneProcessingInstructionImpl.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.OzoneProcessingInstruction;
16
17 import java.util.Map JavaDoc;
18
19 /**
20  *
21  * @author Per Nyfelt
22  */

23 public class OzoneProcessingInstructionImpl extends DefaultProcessingInstruction implements OzoneProcessingInstruction, OzoneCompatible {
24
25     final static long serialVersionUID = 1L;
26
27     private void init() {
28     }
29
30     public static OzoneProcessingInstruction create(OzoneInterface db, String JavaDoc target, Map JavaDoc data) {
31         final Class JavaDoc[] signature = new Class JavaDoc[] {String JavaDoc.class, Map JavaDoc.class};
32         return (OzoneProcessingInstruction) db.createObject(OzoneProcessingInstructionImpl.class,
33                 signature,
34                 new Object JavaDoc[]{target, data});
35     }
36
37     /** <p>This will create a new PI with the given target and values</p>
38      *
39      * @param target is the name of the PI
40      * @param values is the <code>Map</code> values for the PI
41      */

42     public OzoneProcessingInstructionImpl(String JavaDoc target, Map JavaDoc values) {
43         super(target, values);
44         init();
45     }
46
47     public static OzoneProcessingInstruction create(OzoneInterface db, String JavaDoc target, String JavaDoc text) {
48         final Class JavaDoc[] signature = new Class JavaDoc[] {String JavaDoc.class, String JavaDoc.class};
49         return (OzoneProcessingInstruction) db.createObject(OzoneProcessingInstructionImpl.class,
50                 signature,
51                 new Object JavaDoc[]{target, text});
52     }
53
54     public OzoneProcessingInstructionImpl(String JavaDoc target, String JavaDoc text) {
55         super(target, text);
56         init();
57     }
58
59     public static OzoneProcessingInstruction create(OzoneInterface db, Element parent, String JavaDoc target, String JavaDoc values) {
60         final Class JavaDoc[] signature = new Class JavaDoc[] {Element.class, String JavaDoc.class, String JavaDoc.class};
61         return (OzoneProcessingInstruction) db.createObject(OzoneProcessingInstructionImpl.class,
62                 signature,
63                 new Object JavaDoc[]{parent, target, values});
64     }
65
66     /** <p>This will create a new PI with the given target and values</p>
67      *
68      * @param parent is the parent element
69      * @param target is the name of the PI
70      * @param values is the values for the PI
71      */

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