KickJava   Java API By Example, From Geeks To Geeks.

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


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: LazyCDATASection.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.CDATASectionImpl;
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.Node JavaDoc;
29
30 /**
31  * Lazy CDATASection node.
32  */

33 public class LazyCDATASection extends CDATASectionImpl 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 data The node data.
39      */

40     protected LazyCDATASection(LazyDocument ownerDoc,
41                                LazyCDATASection template,
42                                String JavaDoc data) {
43         super(ownerDoc,
44               (template != null) ? template.getData() : data);
45         if (template != null) {
46             fTemplateNode = template;
47             fNodeId = template.getNodeId();
48         }
49     }
50
51     //-------------------------------------------------------------------------
52
// LazyCDATASection specific
53
//-------------------------------------------------------------------------
54

55     /**
56      * Template for this .
57      */

58     private LazyCDATASection fTemplateNode = null;
59
60     /**
61      * Get the template for this node.
62      * @see LazyNode#getTemplateNode
63      */

64     public LazyCDATASection getTemplateCDATASection() {
65         return fTemplateNode;
66     }
67
68     /**
69      * @see Node#cloneNode
70      */

71     public Node JavaDoc cloneNode(boolean deep) {
72         // Just creats a new node with the same value
73
return super.cloneNode(deep);
74     }
75
76     //-------------------------------------------------------------------------
77
// LazyNode support
78
//-------------------------------------------------------------------------
79

80     /*
81      * Node id for this element.
82      */

83     private int fNodeId = NULL_NODE_ID;
84
85     /**
86      * Is this a template node?
87      */

88     private boolean fIsTemplateNode;
89
90     /*
91      * @see LazyNode#makeTemplateNode
92      */

93     public void makeTemplateNode(int nodeId) {
94         fNodeId = nodeId;
95         fIsTemplateNode = true;
96     }
97
98     /**
99      * @see LazyNode#getNodeId
100      */

101     public int getNodeId() {
102         return fNodeId;
103     }
104
105     /**
106      * @see LazyNode#isTemplateNode
107      */

108     public boolean isTemplateNode() {
109         return fIsTemplateNode;
110     }
111
112     /**
113      * @see LazyNode#getTemplateNode
114      */

115     public LazyNode getTemplateNode() {
116         return fTemplateNode;
117     }
118
119     /**
120      * @see LazyNode#templateClone
121      */

122     public LazyNode templateClone(Document JavaDoc ownerDocument) {
123         return new LazyCDATASection((LazyDocument)ownerDocument, this, null);
124     }
125
126     /**
127      * Set the node value, invalidating the id. All node data is modified
128      * by this routine.
129      * @see org.w3c.dom.Node#setNodeValue
130      */

131     public void setNodeValue(String JavaDoc value) {
132         fNodeId = NULL_NODE_ID;
133         super.setNodeValue(value);
134     }
135
136 }
137
Popular Tags