KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > NotationImpl


1 /*
2  * Copyright 1999-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.dom;
18
19 import org.apache.xerces.util.URI;
20 import org.w3c.dom.DOMException JavaDoc;
21 import org.w3c.dom.Node JavaDoc;
22 import org.w3c.dom.Notation JavaDoc;
23
24 /**
25  * Notations are how the Document Type Description (DTD) records hints
26  * about the format of an XML "unparsed entity" -- in other words,
27  * non-XML data bound to this document type, which some applications
28  * may wish to consult when manipulating the document. A Notation
29  * represents a name-value pair, with its nodeName being set to the
30  * declared name of the notation.
31  * <P>
32  * Notations are also used to formally declare the "targets" of
33  * Processing Instructions.
34  * <P>
35  * Note that the Notation's data is non-DOM information; the DOM only
36  * records what and where it is.
37  * <P>
38  * See the XML 1.0 spec, sections 4.7 and 2.6, for more info.
39  * <P>
40  * Level 1 of the DOM does not support editing Notation contents.
41  *
42  * @xerces.internal
43  *
44  * @version $Id: NotationImpl.java,v 1.20 2004/10/05 17:12:50 mrglavas Exp $
45  * @since PR-DOM-Level-1-19980818.
46  */

47 public class NotationImpl
48     extends NodeImpl
49     implements Notation JavaDoc {
50
51     //
52
// Constants
53
//
54

55     /** Serialization version. */
56     static final long serialVersionUID = -764632195890658402L;
57     
58     //
59
// Data
60
//
61

62     /** Notation name. */
63     protected String JavaDoc name;
64
65     /** Public identifier. */
66     protected String JavaDoc publicId;
67
68     /** System identifier. */
69     protected String JavaDoc systemId;
70
71     /** Base URI*/
72     protected String JavaDoc baseURI;
73
74     //
75
// Constructors
76
//
77

78     /** Factory constructor. */
79     public NotationImpl(CoreDocumentImpl ownerDoc, String JavaDoc name) {
80         super(ownerDoc);
81         this.name = name;
82     }
83     
84     //
85
// Node methods
86
//
87

88     /**
89      * A short integer indicating what type of node this is. The named
90      * constants for this value are defined in the org.w3c.dom.Node interface.
91      */

92     public short getNodeType() {
93         return Node.NOTATION_NODE;
94     }
95
96     /**
97      * Returns the notation name
98      */

99     public String JavaDoc getNodeName() {
100         if (needsSyncData()) {
101             synchronizeData();
102         }
103         return name;
104     }
105
106     //
107
// Notation methods
108
//
109

110     /**
111      * The Public Identifier for this Notation. If no public identifier
112      * was specified, this will be null.
113      */

114     public String JavaDoc getPublicId() {
115
116         if (needsSyncData()) {
117             synchronizeData();
118         }
119         return publicId;
120
121     } // getPublicId():String
122

123     /**
124      * The System Identifier for this Notation. If no system identifier
125      * was specified, this will be null.
126      */

127     public String JavaDoc getSystemId() {
128
129         if (needsSyncData()) {
130             synchronizeData();
131         }
132         return systemId;
133
134     } // getSystemId():String
135

136     //
137
// Public methods
138
//
139

140     /**
141      * NON-DOM: The Public Identifier for this Notation. If no public
142      * identifier was specified, this will be null.
143      */

144     public void setPublicId(String JavaDoc id) {
145
146         if (isReadOnly()) {
147             throw new DOMException JavaDoc(
148             DOMException.NO_MODIFICATION_ALLOWED_ERR,
149                 DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
150         }
151         if (needsSyncData()) {
152             synchronizeData();
153         }
154         publicId = id;
155
156     } // setPublicId(String)
157

158     /**
159      * NON-DOM: The System Identifier for this Notation. If no system
160      * identifier was specified, this will be null.
161      */

162     public void setSystemId(String JavaDoc id) {
163
164         if(isReadOnly()) {
165             throw new DOMException JavaDoc(
166             DOMException.NO_MODIFICATION_ALLOWED_ERR,
167                 DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
168         }
169         if (needsSyncData()) {
170             synchronizeData();
171         }
172         systemId = id;
173
174     } // setSystemId(String)
175

176
177     /**
178      * Returns the absolute base URI of this node or null if the implementation
179      * wasn't able to obtain an absolute URI. Note: If the URI is malformed, a
180      * null is returned.
181      *
182      * @return The absolute base URI of this node or null.
183      * @since DOM Level 3
184      */

185     public String JavaDoc getBaseURI() {
186         if (needsSyncData()) {
187             synchronizeData();
188         }
189         if (baseURI != null && baseURI.length() != 0 ) {// attribute value is always empty string
190
try {
191                 return new URI(baseURI).toString();
192             }
193             catch (org.apache.xerces.util.URI.MalformedURIException e){
194                 // REVISIT: what should happen in this case?
195
return null;
196             }
197         }
198         return baseURI;
199     }
200
201     /** NON-DOM: set base uri*/
202     public void setBaseURI(String JavaDoc uri){
203         if (needsSyncData()) {
204             synchronizeData();
205         }
206         baseURI = uri;
207     }
208
209 } // class NotationImpl
210
Popular Tags