KickJava   Java API By Example, From Geeks To Geeks.

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


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

33 public class LazyComment extends CommentImpl 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. Will be ignored if template is not-null.
39      */

40     public LazyComment(LazyDocument ownerDoc,
41                        LazyComment 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
// LazyComment specific
53
//-------------------------------------------------------------------------
54

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

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

64     public LazyComment getTemplateComment() {
65         return fTemplateNode;
66     }
67
68     /**
69      * @see LazyNode#templateClone
70      */

71     public LazyNode templateClone(Document JavaDoc ownerDocument) {
72         return new LazyComment((LazyDocument)ownerDocument, this, null);
73     }
74
75     /**
76      * @see Node#cloneNode
77      */

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

87     /*
88      * Node id for this element.
89      */

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

95     private boolean fIsTemplateNode;
96
97     /*
98      * @see LazyNode#makeTemplateNode
99      */

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

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

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

122     public LazyNode getTemplateNode() {
123         return fTemplateNode;
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