1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| package org.apache.xindice.xml.dom; |
21 |
| |
22 |
| import org.w3c.dom.Attr; |
23 |
| import org.w3c.dom.DOMException; |
24 |
| import org.w3c.dom.Element; |
25 |
| import org.w3c.dom.Node; |
26 |
| import org.w3c.dom.TypeInfo; |
27 |
| import org.w3c.dom.UserDataHandler; |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| public final class AttrImpl extends ContainerNodeImpl |
35 |
| implements Attr { |
36 |
| |
37 |
| private boolean specified = true; |
38 |
| private short symbolID = -1; |
39 |
| |
40 |
| |
41 |
0
| public AttrImpl() {
|
42 |
| } |
43 |
| |
44 |
0
| public AttrImpl(NodeImpl parent, byte[] data, int pos, int len) {
|
45 |
0
| super(parent, data, pos, len);
|
46 |
| } |
47 |
| |
48 |
80745
| public AttrImpl(NodeImpl parent, String nodeName, String nsURI, short symbolID, String nodeValue) {
|
49 |
80745
| super(parent, false);
|
50 |
80745
| this.nodeName = nodeName;
|
51 |
80745
| this.nsURI = nsURI;
|
52 |
80745
| this.symbolID = symbolID;
|
53 |
80745
| this.nodeValue = nodeValue;
|
54 |
| |
55 |
80745
| TextImpl text = new TextImpl(this, false);
|
56 |
80745
| text.nodeValue = nodeValue;
|
57 |
80745
| childNodes.add(text);
|
58 |
| } |
59 |
| |
60 |
0
| public AttrImpl(NodeImpl parent, boolean dirty) {
|
61 |
0
| super(parent, dirty);
|
62 |
| } |
63 |
| |
64 |
137282
| public AttrImpl(NodeImpl parent, String nodeName) {
|
65 |
137282
| super(parent, true);
|
66 |
137282
| this.nodeName = nodeName;
|
67 |
| } |
68 |
| |
69 |
2001145
| public short getNodeType() {
|
70 |
2001146
| return Node.ATTRIBUTE_NODE;
|
71 |
| } |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
279424
| public String getName() {
|
77 |
279424
| return getNodeName();
|
78 |
| } |
79 |
| |
80 |
0
| public void setSymbolID(short symbolID) {
|
81 |
0
| this.symbolID = symbolID;
|
82 |
| } |
83 |
| |
84 |
0
| public short getSymbolID() {
|
85 |
0
| return symbolID;
|
86 |
| } |
87 |
| |
88 |
137264
| public void setNodeValue(String nodeValue) throws DOMException {
|
89 |
137264
| checkLoaded();
|
90 |
137264
| checkReadOnly();
|
91 |
| |
92 |
137264
| childNodes.clear();
|
93 |
137264
| TextImpl text = new TextImpl(this, false);
|
94 |
137264
| text.nodeValue = nodeValue;
|
95 |
137264
| childNodes.add(text);
|
96 |
137264
| setDirty();
|
97 |
| } |
98 |
| |
99 |
137264
| public void setValue(String value) {
|
100 |
137264
| setNodeValue(value);
|
101 |
| } |
102 |
| |
103 |
27
| protected boolean isNodeTypeValid(short type) {
|
104 |
27
| return type == Node.TEXT_NODE ||
|
105 |
| type == Node.ENTITY_REFERENCE_NODE; |
106 |
| } |
107 |
| |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| |
116 |
| |
117 |
| |
118 |
| |
119 |
| |
120 |
| |
121 |
| |
122 |
| |
123 |
| |
124 |
| |
125 |
| |
126 |
| |
127 |
| |
128 |
1816
| public boolean getSpecified() {
|
129 |
1816
| checkLoaded();
|
130 |
1816
| return specified;
|
131 |
| } |
132 |
| |
133 |
0
| public void setSpecified(boolean specified) {
|
134 |
0
| checkLoaded();
|
135 |
0
| this.specified = specified;
|
136 |
| } |
137 |
| |
138 |
| |
139 |
| |
140 |
| |
141 |
| |
142 |
| |
143 |
| |
144 |
| |
145 |
192313
| public String getValue() {
|
146 |
192313
| return getNodeValue();
|
147 |
| } |
148 |
| |
149 |
192627
| public String getNodeValue() {
|
150 |
192627
| StringBuffer sb = new StringBuffer();
|
151 |
192627
| int size = childNodes.getLength();
|
152 |
192627
| for (int i = 0; i < size; i++) {
|
153 |
192627
| sb.append(childNodes.item(i).getNodeValue());
|
154 |
| } |
155 |
| |
156 |
192627
| return sb.toString();
|
157 |
| } |
158 |
| |
159 |
| |
160 |
| |
161 |
| |
162 |
2
| public Element getOwnerElement() {
|
163 |
2
| if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
|
164 |
2
| return (Element) parentNode;
|
165 |
| } else { |
166 |
0
| return null;
|
167 |
| } |
168 |
| } |
169 |
| |
170 |
| |
171 |
| |
172 |
| |
173 |
| |
174 |
| |
175 |
| |
176 |
| |
177 |
0
| public TypeInfo getSchemaTypeInfo() {
|
178 |
0
| return null;
|
179 |
| } |
180 |
| |
181 |
| |
182 |
| |
183 |
| |
184 |
0
| public boolean isId() {
|
185 |
0
| return false;
|
186 |
| } |
187 |
| |
188 |
2
| Node renameNode(String namespaceURI, String qualifiedName, String prefix) {
|
189 |
2
| checkLoaded();
|
190 |
2
| checkReadOnly();
|
191 |
| |
192 |
2
| if ((XMLNS_PREFIX.equals(prefix) || XMLNS_PREFIX.equals(qualifiedName)) &&
|
193 |
| !XMLNS_URI.equals(namespaceURI)) { |
194 |
0
| throw new DOMException(DOMException.NAMESPACE_ERR, XMLNS_PREFIX + " prefix is reserved.");
|
195 |
| } |
196 |
| |
197 |
2
| nodeName = qualifiedName;
|
198 |
2
| if (prefix != null) {
|
199 |
2
| getOwnerElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, namespaceURI);
|
200 |
| } |
201 |
| |
202 |
2
| invokeHandlers(UserDataHandler.NODE_RENAMED, this, null);
|
203 |
2
| return this;
|
204 |
| } |
205 |
| } |