KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > lazydom > LazyProcessingInstruction


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: LazyProcessingInstruction.java,v 1.3 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.lazydom;
25
26 import org.enhydra.apache.xerces.dom.ProcessingInstructionImpl;
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.Node JavaDoc;
29
30 /**
31  * Lazy text node.
32  */

33 public class LazyProcessingInstruction extends ProcessingInstructionImpl implements LazyNode {
34     /**
35      * Constructor.
36      * @param ownerDoc The document that owns this node.
37      * @param template If not-null, get the parameters from this template.
38      * @param target The target of the PI.
39      * Will be ignored if template is not-null.
40      * @param data The data of the PI.
41      * Will be ignored if template is not-null.
42      */

43     protected LazyProcessingInstruction(LazyDocument ownerDoc,
44                                         LazyProcessingInstruction template,
45                                         String JavaDoc target,
46                                         String JavaDoc data) {
47         super(ownerDoc,
48               (template != null) ? template.getTarget() : target,
49               (template != null) ? template.getData() : data);
50         if (template != null) {
51             fTemplateNode = template;
52             fNodeId = template.getNodeId();
53         }
54     }
55
56     //-------------------------------------------------------------------------
57
// LazyProcessingInstruction specific
58
//-------------------------------------------------------------------------
59

60     /**
61      * Template for this ProcessingInstruction.
62      */

63     private LazyProcessingInstruction fTemplateNode = null;
64
65     /**
66      * Get the template for this node.
67      * @see LazyNode#getTemplateNode
68      */

69     public LazyProcessingInstruction getTemplateProcessingInstruction() {
70         return fTemplateNode;
71     }
72
73     /**
74      * @see Node#cloneNode
75      */

76     public Node JavaDoc cloneNode(boolean deep) {
77         // Just creats a new node with the same value
78
return super.cloneNode(deep);
79     }
80
81     //-------------------------------------------------------------------------
82
// LazyNode support
83
//-------------------------------------------------------------------------
84

85     /*
86      * Node id for this element.
87      */

88     private int fNodeId = NULL_NODE_ID;
89
90     /**
91      * Is this a template node?
92      */

93     private boolean fIsTemplateNode;
94
95     /*
96      * @see LazyNode#makeTemplateNode
97      */

98     public void makeTemplateNode(int nodeId) {
99         fNodeId = nodeId;
100         fIsTemplateNode = true;
101     }
102
103     /**
104      * @see LazyNode#getNodeId
105      */

106     public int getNodeId() {
107         return fNodeId;
108     }
109
110     /**
111      * @see LazyNode#isTemplateNode
112      */

113     public boolean isTemplateNode() {
114         return fIsTemplateNode;
115     }
116
117     /**
118      * @see LazyNode#getTemplateNode
119      */

120     public LazyNode getTemplateNode() {
121         return fTemplateNode;
122     }
123
124     /**
125      * @see LazyNode#templateClone
126      */

127     public LazyNode templateClone(Document JavaDoc ownerDocument) {
128         return new LazyProcessingInstruction((LazyDocument)ownerDocument, this,
129                                              null, null);
130     }
131
132     /**
133      * Set the node value, invalidating the id. All node data is modified
134      * by this routine.
135      * @see org.w3c.dom.Node#setNodeValue
136      */

137     public void setNodeValue(String JavaDoc value) {
138         fNodeId = NULL_NODE_ID;
139         super.setNodeValue(value);
140     }
141
142 }
143
Popular Tags