KickJava   Java API By Example, From Geeks To Geeks.

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


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

33 public class LazyNotation extends NotationImpl 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 name Document type name.
39      * Will be ignored if template is not-null.
40      * @param publicId The public id.
41      * Will be ignored if template is not-null.
42      * @param systemId The system id.
43      * Will be ignored if template is not-null.
44      */

45     protected LazyNotation(LazyDocument ownerDoc,
46                            LazyNotation template,
47                            String JavaDoc name,
48                            String JavaDoc publicId,
49                            String JavaDoc systemId) {
50         super(ownerDoc,
51               (template != null) ? template.getNodeName() : name);
52         if (template != null) {
53             if (template.getPublicId() != null) {
54                 setPublicId(template.getPublicId());
55             }
56             if (template.getSystemId() != null) {
57                 setSystemId(template.getSystemId());
58             }
59             fTemplateNode = template;
60             fNodeId = template.getNodeId();
61         } else {
62             if (publicId != null) {
63                 setPublicId(publicId);
64             }
65             if (systemId != null) {
66                 setSystemId(systemId);
67             }
68         }
69     }
70
71     //-------------------------------------------------------------------------
72
// LazyNotation specific
73
//-------------------------------------------------------------------------
74

75     /**
76      * Template for this Notation.
77      */

78     private LazyNotation fTemplateNode = null;
79
80     /**
81      * Get the template for this node.
82      * @see LazyNode#getTemplateNode
83      */

84     public LazyNotation getTemplateNotation() {
85         return fTemplateNode;
86     }
87
88     /**
89      * @see Node#cloneNode
90      */

91     public Node JavaDoc cloneNode(boolean deep) {
92         // This does a clone(), must clean up all fields.
93
LazyNotation newNotation = (LazyNotation)super.cloneNode(deep);
94         newNotation.fNodeId = NULL_NODE_ID;
95         return newNotation;
96     }
97
98     //-------------------------------------------------------------------------
99
// LazyNode support
100
//-------------------------------------------------------------------------
101

102     /*
103      * Node id for this element.
104      */

105     private int fNodeId = NULL_NODE_ID;
106
107     /**
108      * Is this a template node?
109      */

110     private boolean fIsTemplateNode;
111
112     /*
113      * @see LazyNode#makeTemplateNode
114      */

115     public void makeTemplateNode(int nodeId) {
116         fNodeId = nodeId;
117         fIsTemplateNode = true;
118     }
119
120     /**
121      * @see LazyNode#getNodeId
122      */

123     public int getNodeId() {
124         return fNodeId;
125     }
126
127     /**
128      * @see LazyNode#isTemplateNode
129      */

130     public boolean isTemplateNode() {
131         return fIsTemplateNode;
132     }
133
134     /**
135      * @see LazyNode#getTemplateNode
136      */

137     public LazyNode getTemplateNode() {
138         return fTemplateNode;
139     }
140
141     /**
142      * @see LazyNode#templateClone
143      */

144     public LazyNode templateClone(Document JavaDoc ownerDocument) {
145         return new LazyNotation((LazyDocument)ownerDocument, this,
146                                 null, null, null);
147     }
148
149     /**
150      * Set the node value, invalidating the id. All node data is modified
151      * by this routine.
152      * @see org.w3c.dom.Node#setNodeValue
153      */

154     public void setNodeValue(String JavaDoc value) {
155         fNodeId = NULL_NODE_ID;
156         super.setNodeValue(value);
157     }
158
159 }
160
Popular Tags