6
|
1 |
/*
|
|
2 |
* reserved comment block
|
|
3 |
* DO NOT REMOVE OR ALTER!
|
|
4 |
*/
|
|
5 |
/*
|
|
6 |
* Copyright 1999-2002,2004 The Apache Software Foundation.
|
|
7 |
*
|
|
8 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9 |
* you may not use this file except in compliance with the License.
|
|
10 |
* You may obtain a copy of the License at
|
|
11 |
*
|
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13 |
*
|
|
14 |
* Unless required by applicable law or agreed to in writing, software
|
|
15 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17 |
* See the License for the specific language governing permissions and
|
|
18 |
* limitations under the License.
|
|
19 |
*/
|
|
20 |
|
|
21 |
package com.sun.org.apache.xerces.internal.dom;
|
|
22 |
|
|
23 |
import com.sun.org.apache.xerces.internal.util.URI;
|
|
24 |
import org.w3c.dom.DOMException;
|
|
25 |
import org.w3c.dom.Node;
|
|
26 |
import org.w3c.dom.Notation;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* Notations are how the Document Type Description (DTD) records hints
|
|
30 |
* about the format of an XML "unparsed entity" -- in other words,
|
|
31 |
* non-XML data bound to this document type, which some applications
|
|
32 |
* may wish to consult when manipulating the document. A Notation
|
|
33 |
* represents a name-value pair, with its nodeName being set to the
|
|
34 |
* declared name of the notation.
|
|
35 |
* <P>
|
|
36 |
* Notations are also used to formally declare the "targets" of
|
|
37 |
* Processing Instructions.
|
|
38 |
* <P>
|
|
39 |
* Note that the Notation's data is non-DOM information; the DOM only
|
|
40 |
* records what and where it is.
|
|
41 |
* <P>
|
|
42 |
* See the XML 1.0 spec, sections 4.7 and 2.6, for more info.
|
|
43 |
* <P>
|
|
44 |
* Level 1 of the DOM does not support editing Notation contents.
|
|
45 |
*
|
|
46 |
* @xerces.internal
|
|
47 |
*
|
|
48 |
* @since PR-DOM-Level-1-19980818.
|
|
49 |
*/
|
|
50 |
public class NotationImpl
|
|
51 |
extends NodeImpl
|
|
52 |
implements Notation {
|
|
53 |
|
|
54 |
//
|
|
55 |
// Constants
|
|
56 |
//
|
|
57 |
|
|
58 |
/** Serialization version. */
|
|
59 |
static final long serialVersionUID = -764632195890658402L;
|
|
60 |
|
|
61 |
//
|
|
62 |
// Data
|
|
63 |
//
|
|
64 |
|
|
65 |
/** Notation name. */
|
|
66 |
protected String name;
|
|
67 |
|
|
68 |
/** Public identifier. */
|
|
69 |
protected String publicId;
|
|
70 |
|
|
71 |
/** System identifier. */
|
|
72 |
protected String systemId;
|
|
73 |
|
|
74 |
/** Base URI*/
|
|
75 |
protected String baseURI;
|
|
76 |
|
|
77 |
//
|
|
78 |
// Constructors
|
|
79 |
//
|
|
80 |
|
|
81 |
/** Factory constructor. */
|
|
82 |
public NotationImpl(CoreDocumentImpl ownerDoc, String name) {
|
|
83 |
super(ownerDoc);
|
|
84 |
this.name = name;
|
|
85 |
}
|
|
86 |
|
|
87 |
//
|
|
88 |
// Node methods
|
|
89 |
//
|
|
90 |
|
|
91 |
/**
|
|
92 |
* A short integer indicating what type of node this is. The named
|
|
93 |
* constants for this value are defined in the org.w3c.dom.Node interface.
|
|
94 |
*/
|
|
95 |
public short getNodeType() {
|
|
96 |
return Node.NOTATION_NODE;
|
|
97 |
}
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Returns the notation name
|
|
101 |
*/
|
|
102 |
public String getNodeName() {
|
|
103 |
if (needsSyncData()) {
|
|
104 |
synchronizeData();
|
|
105 |
}
|
|
106 |
return name;
|
|
107 |
}
|
|
108 |
|
|
109 |
//
|
|
110 |
// Notation methods
|
|
111 |
//
|
|
112 |
|
|
113 |
/**
|
|
114 |
* The Public Identifier for this Notation. If no public identifier
|
|
115 |
* was specified, this will be null.
|
|
116 |
*/
|
|
117 |
public String getPublicId() {
|
|
118 |
|
|
119 |
if (needsSyncData()) {
|
|
120 |
synchronizeData();
|
|
121 |
}
|
|
122 |
return publicId;
|
|
123 |
|
|
124 |
} // getPublicId():String
|
|
125 |
|
|
126 |
/**
|
|
127 |
* The System Identifier for this Notation. If no system identifier
|
|
128 |
* was specified, this will be null.
|
|
129 |
*/
|
|
130 |
public String getSystemId() {
|
|
131 |
|
|
132 |
if (needsSyncData()) {
|
|
133 |
synchronizeData();
|
|
134 |
}
|
|
135 |
return systemId;
|
|
136 |
|
|
137 |
} // getSystemId():String
|
|
138 |
|
|
139 |
//
|
|
140 |
// Public methods
|
|
141 |
//
|
|
142 |
|
|
143 |
/**
|
|
144 |
* NON-DOM: The Public Identifier for this Notation. If no public
|
|
145 |
* identifier was specified, this will be null.
|
|
146 |
*/
|
|
147 |
public void setPublicId(String id) {
|
|
148 |
|
|
149 |
if (isReadOnly()) {
|
|
150 |
throw new DOMException(
|
|
151 |
DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
|
152 |
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
|
|
153 |
}
|
|
154 |
if (needsSyncData()) {
|
|
155 |
synchronizeData();
|
|
156 |
}
|
|
157 |
publicId = id;
|
|
158 |
|
|
159 |
} // setPublicId(String)
|
|
160 |
|
|
161 |
/**
|
|
162 |
* NON-DOM: The System Identifier for this Notation. If no system
|
|
163 |
* identifier was specified, this will be null.
|
|
164 |
*/
|
|
165 |
public void setSystemId(String id) {
|
|
166 |
|
|
167 |
if(isReadOnly()) {
|
|
168 |
throw new DOMException(
|
|
169 |
DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
|
170 |
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
|
|
171 |
}
|
|
172 |
if (needsSyncData()) {
|
|
173 |
synchronizeData();
|
|
174 |
}
|
|
175 |
systemId = id;
|
|
176 |
|
|
177 |
} // setSystemId(String)
|
|
178 |
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Returns the absolute base URI of this node or null if the implementation
|
|
182 |
* wasn't able to obtain an absolute URI. Note: If the URI is malformed, a
|
|
183 |
* null is returned.
|
|
184 |
*
|
|
185 |
* @return The absolute base URI of this node or null.
|
|
186 |
* @since DOM Level 3
|
|
187 |
*/
|
|
188 |
public String getBaseURI() {
|
|
189 |
if (needsSyncData()) {
|
|
190 |
synchronizeData();
|
|
191 |
}
|
|
192 |
if (baseURI != null && baseURI.length() != 0 ) {// attribute value is always empty string
|
|
193 |
try {
|
|
194 |
return new URI(baseURI).toString();
|
|
195 |
}
|
|
196 |
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){
|
|
197 |
// REVISIT: what should happen in this case?
|
|
198 |
return null;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
return baseURI;
|
|
202 |
}
|
|
203 |
|
|
204 |
/** NON-DOM: set base uri*/
|
|
205 |
public void setBaseURI(String uri){
|
|
206 |
if (needsSyncData()) {
|
|
207 |
synchronizeData();
|
|
208 |
}
|
|
209 |
baseURI = uri;
|
|
210 |
}
|
|
211 |
|
|
212 |
} // class NotationImpl
|