1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| package org.apache.xindice.util; |
21 |
| |
22 |
| import org.apache.commons.logging.Log; |
23 |
| import org.apache.commons.logging.LogFactory; |
24 |
| |
25 |
| import org.w3c.dom.Attr; |
26 |
| import org.w3c.dom.Document; |
27 |
| import org.w3c.dom.Element; |
28 |
| import org.w3c.dom.NamedNodeMap; |
29 |
| import org.w3c.dom.Node; |
30 |
| import org.w3c.dom.NodeList; |
31 |
| import org.w3c.dom.Text; |
32 |
| |
33 |
| import java.util.ArrayList; |
34 |
| import java.util.List; |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| public final class Configuration { |
45 |
| |
46 |
| private static final Log log = LogFactory.getLog(Configuration.class); |
47 |
| |
48 |
| private static final Configuration[] EMPTY = new Configuration[0]; |
49 |
| |
50 |
| private Element config; |
51 |
| private boolean readOnly; |
52 |
| private boolean isDirty; |
53 |
| private Configuration root; |
54 |
| |
55 |
| |
56 |
1797
| public Configuration(Element config, boolean readOnly) {
|
57 |
1797
| this.config = config;
|
58 |
1797
| this.readOnly = readOnly;
|
59 |
| } |
60 |
| |
61 |
963
| public Configuration(Document config, boolean readOnly) {
|
62 |
963
| this(config.getDocumentElement(), readOnly);
|
63 |
| } |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
288
| public Configuration(Element config) {
|
70 |
288
| this(config, true);
|
71 |
| } |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
| |
77 |
288
| public Configuration(Document config) {
|
78 |
288
| this(config.getDocumentElement());
|
79 |
| } |
80 |
| |
81 |
7407
| private Configuration(Configuration root, Element config, boolean readOnly) {
|
82 |
7407
| this.root = root;
|
83 |
7407
| this.config = config;
|
84 |
7407
| this.readOnly = readOnly;
|
85 |
| } |
86 |
| |
87 |
18754
| private void setDirty() {
|
88 |
18754
| if (root != null) {
|
89 |
15228
| root.setDirty();
|
90 |
| } else { |
91 |
3526
| this.isDirty = true;
|
92 |
| } |
93 |
| } |
94 |
| |
95 |
2355
| public void resetDirty() {
|
96 |
| |
97 |
2355
| this.isDirty = false;
|
98 |
| } |
99 |
| |
100 |
7866
| public boolean isDirty() {
|
101 |
7866
| if (root != null) {
|
102 |
1
| return root.isDirty();
|
103 |
| } else { |
104 |
7865
| return isDirty;
|
105 |
| } |
106 |
| } |
107 |
| |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| |
116 |
| |
117 |
2484
| public Element getElement() throws ReadOnlyException {
|
118 |
2484
| if (readOnly) {
|
119 |
0
| throw new ReadOnlyException();
|
120 |
| } |
121 |
2484
| return config;
|
122 |
| } |
123 |
| |
124 |
| |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
1235
| public String getName() {
|
130 |
1235
| return config.getNodeName();
|
131 |
| } |
132 |
| |
133 |
| |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
| |
139 |
17
| public boolean hasAttributes() {
|
140 |
17
| return config.getAttributes().getLength() > 0;
|
141 |
| } |
142 |
| |
143 |
| |
144 |
| |
145 |
| |
146 |
| |
147 |
| |
148 |
| |
149 |
| |
150 |
13174
| public String getAttribute(String name, String defValue) {
|
151 |
13174
| String value = config.getAttribute(name);
|
152 |
13174
| if (value == null || value.length() == 0) {
|
153 |
3882
| value = defValue;
|
154 |
| } |
155 |
13174
| return value;
|
156 |
| } |
157 |
| |
158 |
| |
159 |
| |
160 |
| |
161 |
| |
162 |
| |
163 |
| |
164 |
7254
| public String getAttribute(String name) {
|
165 |
7254
| return getAttribute(name, "");
|
166 |
| } |
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
| |
172 |
| |
173 |
| |
174 |
| |
175 |
5828
| public boolean getBooleanAttribute(String name, boolean defValue) {
|
176 |
5828
| try {
|
177 |
5828
| String attr = getAttribute(name, defValue ? "1" : "0").toLowerCase();
|
178 |
5828
| return "[true][yes][1][y][on]".indexOf("[" + attr + "]") != -1;
|
179 |
| } catch (Exception e) { |
180 |
0
| return defValue;
|
181 |
| } |
182 |
| } |
183 |
| |
184 |
| |
185 |
| |
186 |
| |
187 |
| |
188 |
| |
189 |
| |
190 |
1
| public boolean getBooleanAttribute(String name) {
|
191 |
1
| return getBooleanAttribute(name, false);
|
192 |
| } |
193 |
| |
194 |
| |
195 |
| |
196 |
| |
197 |
| |
198 |
| |
199 |
| |
200 |
| |
201 |
2823
| public int getIntAttribute(String name, int defValue) {
|
202 |
2823
| try {
|
203 |
2823
| return Integer.parseInt(config.getAttribute(name));
|
204 |
| } catch (Exception e) { |
205 |
2266
| return defValue;
|
206 |
| } |
207 |
| } |
208 |
| |
209 |
| |
210 |
| |
211 |
| |
212 |
| |
213 |
| |
214 |
| |
215 |
1
| public int getIntAttribute(String name) {
|
216 |
1
| return getIntAttribute(name, 0);
|
217 |
| } |
218 |
| |
219 |
| |
220 |
| |
221 |
| |
222 |
| |
223 |
| |
224 |
| |
225 |
| |
226 |
3970
| public short getShortAttribute(String name, short defValue) {
|
227 |
3970
| try {
|
228 |
3970
| return Short.parseShort(config.getAttribute(name));
|
229 |
| } catch (Exception e) { |
230 |
3970
| return defValue;
|
231 |
| } |
232 |
| } |
233 |
| |
234 |
| |
235 |
| |
236 |
| |
237 |
| |
238 |
| |
239 |
| |
240 |
0
| public short getShortAttribute(String name) {
|
241 |
0
| return getShortAttribute(name, (short) 0);
|
242 |
| } |
243 |
| |
244 |
| |
245 |
| |
246 |
| |
247 |
| |
248 |
| |
249 |
| |
250 |
| |
251 |
1411
| public long getLongAttribute(String name, long defValue) {
|
252 |
1411
| try {
|
253 |
1411
| return Long.parseLong(config.getAttribute(name));
|
254 |
| } catch (Exception e) { |
255 |
1249
| return defValue;
|
256 |
| } |
257 |
| } |
258 |
| |
259 |
| |
260 |
| |
261 |
| |
262 |
| |
263 |
| |
264 |
| |
265 |
0
| public long getLongAttribute(String name) {
|
266 |
0
| return getLongAttribute(name, (long) 0);
|
267 |
| } |
268 |
| |
269 |
| |
270 |
| |
271 |
| |
272 |
| |
273 |
| |
274 |
| |
275 |
| |
276 |
0
| public float getFloatAttribute(String name, float defValue) {
|
277 |
0
| try {
|
278 |
0
| return Float.parseFloat(config.getAttribute(name));
|
279 |
| } catch (Exception e) { |
280 |
0
| return defValue;
|
281 |
| } |
282 |
| } |
283 |
| |
284 |
| |
285 |
| |
286 |
| |
287 |
| |
288 |
| |
289 |
| |
290 |
0
| public float getFloatAttribute(String name) {
|
291 |
0
| return getFloatAttribute(name, (float) 0.0);
|
292 |
| } |
293 |
| |
294 |
| |
295 |
| |
296 |
| |
297 |
| |
298 |
| |
299 |
| |
300 |
| |
301 |
0
| public double getDoubleAttribute(String name, double defValue) {
|
302 |
0
| try {
|
303 |
0
| return Double.parseDouble(config.getAttribute(name));
|
304 |
| } catch (Exception e) { |
305 |
0
| return defValue;
|
306 |
| } |
307 |
| } |
308 |
| |
309 |
| |
310 |
| |
311 |
| |
312 |
| |
313 |
| |
314 |
| |
315 |
0
| public double getDoubleAttribute(String name) {
|
316 |
0
| return getDoubleAttribute(name, 0.0D);
|
317 |
| } |
318 |
| |
319 |
| |
320 |
| |
321 |
| |
322 |
| |
323 |
| |
324 |
| |
325 |
| |
326 |
0
| public byte getByteAttribute(String name, byte defValue) {
|
327 |
0
| try {
|
328 |
0
| return Byte.parseByte(config.getAttribute(name));
|
329 |
| } catch (Exception e) { |
330 |
0
| return defValue;
|
331 |
| } |
332 |
| } |
333 |
| |
334 |
| |
335 |
| |
336 |
| |
337 |
| |
338 |
| |
339 |
| |
340 |
0
| public byte getByteAttribute(String name) {
|
341 |
0
| return getByteAttribute(name, (byte) 0);
|
342 |
| } |
343 |
| |
344 |
| |
345 |
| |
346 |
| |
347 |
| |
348 |
| |
349 |
| |
350 |
| |
351 |
0
| public char getCharAttribute(String name, char defValue) {
|
352 |
0
| try {
|
353 |
0
| return config.getAttribute(name).charAt(0);
|
354 |
| } catch (Exception e) { |
355 |
0
| return defValue;
|
356 |
| } |
357 |
| } |
358 |
| |
359 |
| |
360 |
| |
361 |
| |
362 |
| |
363 |
| |
364 |
| |
365 |
0
| public char getCharAttribute(String name) {
|
366 |
0
| return getCharAttribute(name, '\0');
|
367 |
| } |
368 |
| |
369 |
| |
370 |
| |
371 |
| |
372 |
| |
373 |
| |
374 |
| |
375 |
10
| public String[] listAttributes() {
|
376 |
10
| NamedNodeMap map = config.getAttributes();
|
377 |
10
| String[] result = new String[map.getLength()];
|
378 |
10
| int size = map.getLength();
|
379 |
10
| for (int i = 0; i < size; i++) {
|
380 |
20
| result[i] = ((Attr) map.item(i)).getName();
|
381 |
| } |
382 |
10
| return result;
|
383 |
| } |
384 |
| |
385 |
| |
386 |
| |
387 |
| |
388 |
| |
389 |
| |
390 |
| |
391 |
17
| public boolean hasValue() {
|
392 |
17
| NodeList list = config.getChildNodes();
|
393 |
17
| return (list.getLength() > 0 && list.item(0).getNodeType() == Node.TEXT_NODE);
|
394 |
| } |
395 |
| |
396 |
| |
397 |
| |
398 |
| |
399 |
| |
400 |
| |
401 |
| |
402 |
0
| public String getValue(String defValue) {
|
403 |
0
| NodeList list = config.getChildNodes();
|
404 |
0
| if (list.getLength() == 1 && list.item(0).getNodeType() == Node.TEXT_NODE) {
|
405 |
0
| return list.item(0).getNodeValue();
|
406 |
| } else { |
407 |
0
| return defValue;
|
408 |
| } |
409 |
| } |
410 |
| |
411 |
| |
412 |
| |
413 |
| |
414 |
| |
415 |
| |
416 |
0
| public String getValue() {
|
417 |
0
| return getValue("");
|
418 |
| } |
419 |
| |
420 |
| |
421 |
| |
422 |
| |
423 |
| |
424 |
| |
425 |
| |
426 |
0
| public boolean getBooleanValue(boolean defValue) {
|
427 |
0
| try {
|
428 |
0
| return "[true][yes][1][y][on]".indexOf("[" + getValue().toLowerCase() + "]") != -1;
|
429 |
| } catch (Exception e) { |
430 |
0
| return defValue;
|
431 |
| } |
432 |
| } |
433 |
| |
434 |
| |
435 |
| |
436 |
| |
437 |
| |
438 |
| |
439 |
0
| public boolean getBooleanValue() {
|
440 |
0
| return getBooleanValue(false);
|
441 |
| } |
442 |
| |
443 |
| |
444 |
| |
445 |
| |
446 |
| |
447 |
| |
448 |
| |
449 |
0
| public int getIntValue(int defValue) {
|
450 |
0
| try {
|
451 |
0
| return Integer.parseInt(getValue());
|
452 |
| } catch (Exception e) { |
453 |
0
| return defValue;
|
454 |
| } |
455 |
| } |
456 |
| |
457 |
| |
458 |
| |
459 |
| |
460 |
| |
461 |
| |
462 |
0
| public int getIntValue() {
|
463 |
0
| return getIntValue(0);
|
464 |
| } |
465 |
| |
466 |
| |
467 |
| |
468 |
| |
469 |
| |
470 |
| |
471 |
| |
472 |
0
| public short getShortValue(short defValue) {
|
473 |
0
| try {
|
474 |
0
| return Short.parseShort(getValue());
|
475 |
| } catch (Exception e) { |
476 |
0
| return defValue;
|
477 |
| } |
478 |
| } |
479 |
| |
480 |
| |
481 |
| |
482 |
| |
483 |
| |
484 |
| |
485 |
0
| public short getShortValue() {
|
486 |
0
| return getShortValue((short) 0);
|
487 |
| } |
488 |
| |
489 |
| |
490 |
| |
491 |
| |
492 |
| |
493 |
| |
494 |
| |
495 |
0
| public long getLongValue(long defValue) {
|
496 |
0
| try {
|
497 |
0
| return Long.parseLong(getValue());
|
498 |
| } catch (Exception e) { |
499 |
0
| return defValue;
|
500 |
| } |
501 |
| } |
502 |
| |
503 |
| |
504 |
| |
505 |
| |
506 |
| |
507 |
| |
508 |
0
| public long getLongValue() {
|
509 |
0
| return getLongValue(0);
|
510 |
| } |
511 |
| |
512 |
| |
513 |
| |
514 |
| |
515 |
| |
516 |
| |
517 |
| |
518 |
0
| public float getFloatValue(float defValue) {
|
519 |
0
| try {
|
520 |
0
| return Float.parseFloat(getValue());
|
521 |
| } catch (Exception e) { |
522 |
0
| return defValue;
|
523 |
| } |
524 |
| } |
525 |
| |
526 |
| |
527 |
| |
528 |
| |
529 |
| |
530 |
| |
531 |
0
| public float getFloatValue() {
|
532 |
0
| return getFloatValue((float) 0.0);
|
533 |
| } |
534 |
| |
535 |
| |
536 |
| |
537 |
| |
538 |
| |
539 |
| |
540 |
| |
541 |
0
| public double getDoubleValue(double defValue) {
|
542 |
0
| try {
|
543 |
0
| return Double.parseDouble(getValue());
|
544 |
| } catch (Exception e) { |
545 |
0
| return defValue;
|
546 |
| } |
547 |
| } |
548 |
| |
549 |
| |
550 |
| |
551 |
| |
552 |
| |
553 |
| |
554 |
0
| public double getDoubleValue() {
|
555 |
0
| return getDoubleValue(0.0D);
|
556 |
| } |
557 |
| |
558 |
| |
559 |
| |
560 |
| |
561 |
| |
562 |
| |
563 |
| |
564 |
0
| public byte getByteValue(byte defValue) {
|
565 |
0
| try {
|
566 |
0
| return Byte.parseByte(getValue());
|
567 |
| } catch (Exception e) { |
568 |
0
| return defValue;
|
569 |
| } |
570 |
| } |
571 |
| |
572 |
| |
573 |
| |
574 |
| |
575 |
| |
576 |
| |
577 |
0
| public byte getByteValue() {
|
578 |
0
| return getByteValue((byte) 0);
|
579 |
| } |
580 |
| |
581 |
| |
582 |
| |
583 |
| |
584 |
| |
585 |
| |
586 |
| |
587 |
0
| public char getCharValue(char defValue) {
|
588 |
0
| try {
|
589 |
0
| return getValue().charAt(0);
|
590 |
| } catch (Exception e) { |
591 |
0
| return defValue;
|
592 |
| } |
593 |
| } |
594 |
| |
595 |
| |
596 |
| |
597 |
| |
598 |
| |
599 |
| |
600 |
0
| public char getCharValue() {
|
601 |
0
| return getCharValue('\0');
|
602 |
| } |
603 |
| |
604 |
| |
605 |
| |
606 |
| |
607 |
| |
608 |
| |
609 |
| |
610 |
17
| public boolean hasChildren() {
|
611 |
17
| NodeList list = config.getChildNodes();
|
612 |
17
| int size = list.getLength();
|
613 |
17
| for (int i = 0; i < size; i++) {
|
614 |
7
| if (list.item(i).getNodeType() == Node.ELEMENT_NODE) {
|
615 |
7
| return true;
|
616 |
| } |
617 |
| } |
618 |
| |
619 |
10
| return false;
|
620 |
| } |
621 |
| |
622 |
| |
623 |
| |
624 |
| |
625 |
| |
626 |
| |
627 |
| |
628 |
162
| public Configuration[] getChildren() {
|
629 |
162
| NodeList list = config.getChildNodes();
|
630 |
162
| int size = list.getLength();
|
631 |
| |
632 |
162
| List children = new ArrayList();
|
633 |
162
| for (int i = 0; i < size; i++) {
|
634 |
29
| if (list.item(i).getNodeType() == Node.ELEMENT_NODE) {
|
635 |
25
| children.add(new Configuration(this, (Element) list.item(i), readOnly));
|
636 |
| } |
637 |
| } |
638 |
162
| return (Configuration[]) children.toArray(EMPTY);
|
639 |
| } |
640 |
| |
641 |
| |
642 |
| |
643 |
| |
644 |
| |
645 |
| |
646 |
| |
647 |
0
| public void processChildren(ConfigurationCallback callback) {
|
648 |
0
| NodeList list = config.getChildNodes();
|
649 |
| |
650 |
| |
651 |
0
| Node[] nl = new Node[list.getLength()];
|
652 |
0
| for (int i = 0; i < nl.length; i++) {
|
653 |
0
| nl[i] = list.item(i);
|
654 |
| } |
655 |
| |
656 |
0
| int size = nl.length;
|
657 |
0
| try {
|
658 |
0
| for (int i = 0; i < size; i++) {
|
659 |
0
| if (nl[i].getNodeType() == Node.ELEMENT_NODE) {
|
660 |
0
| callback.process(new Configuration(this, (Element) nl[i], readOnly));
|
661 |
| } |
662 |
| } |
663 |
| } catch (Exception e) { |
664 |
0
| if (log.isWarnEnabled()) {
|
665 |
0
| log.warn("ignored exception", e);
|
666 |
| } |
667 |
| } |
668 |
| } |
669 |
| |
670 |
| |
671 |
| |
672 |
| |
673 |
| |
674 |
| |
675 |
| |
676 |
| |
677 |
3068
| public void processChildren(String name, ConfigurationCallback callback) {
|
678 |
3068
| NodeList list = config.getChildNodes();
|
679 |
| |
680 |
| |
681 |
3068
| Node[] nl = new Node[list.getLength()];
|
682 |
3068
| for (int i = 0; i < nl.length; i++) {
|
683 |
2571
| nl[i] = list.item(i);
|
684 |
| } |
685 |
| |
686 |
3068
| int size = nl.length;
|
687 |
3068
| try {
|
688 |
3068
| for (int i = 0; i < size; i++) {
|
689 |
2571
| if (nl[i].getNodeType() == Node.ELEMENT_NODE && nl[i].getNodeName().equals(name)) {
|
690 |
1934
| callback.process(new Configuration(this, (Element) nl[i], readOnly));
|
691 |
| } |
692 |
| } |
693 |
| } catch (Exception e) { |
694 |
0
| if (log.isWarnEnabled()) {
|
695 |
0
| log.warn("ignored exception", e);
|
696 |
| } |
697 |
| } |
698 |
| } |
699 |
| |
700 |
| |
701 |
| |
702 |
| |
703 |
| |
704 |
| |
705 |
| |
706 |
| |
707 |
71
| public Configuration[] getChildren(String name) {
|
708 |
71
| NodeList list = config.getChildNodes();
|
709 |
71
| int size = list.getLength();
|
710 |
| |
711 |
71
| List children = new ArrayList();
|
712 |
71
| for (int i = 0; i < size; i++) {
|
713 |
223
| if (list.item(i).getNodeType() == Node.ELEMENT_NODE && list.item(i).getNodeName().equals(name)) {
|
714 |
68
| children.add(new Configuration(this, (Element) list.item(i), readOnly));
|
715 |
| } |
716 |
| } |
717 |
| |
718 |
71
| return (Configuration[])children.toArray(EMPTY);
|
719 |
| } |
720 |
| |
721 |
| |
722 |
| |
723 |
| |
724 |
| |
725 |
| |
726 |
| |
727 |
| |
728 |
| |
729 |
| |
730 |
8562
| public Configuration getChild(String name, boolean create) throws ReadOnlyException {
|
731 |
8562
| NodeList list = config.getChildNodes();
|
732 |
8562
| int size = list.getLength();
|
733 |
| |
734 |
8562
| for (int i = 0; i < size; i++) {
|
735 |
21766
| if (list.item(i).getNodeType() == Node.ELEMENT_NODE && list.item(i).getNodeName().equals(name)) {
|
736 |
4237
| return new Configuration(this, (Element) list.item(i), readOnly);
|
737 |
| } |
738 |
| } |
739 |
| |
740 |
4325
| return create? add(name) : null;
|
741 |
| } |
742 |
| |
743 |
| |
744 |
| |
745 |
| |
746 |
| |
747 |
| |
748 |
| |
749 |
| |
750 |
6230
| public Configuration getChild(String name) {
|
751 |
6230
| try {
|
752 |
6230
| return getChild(name, false);
|
753 |
| } catch (Exception e) { |
754 |
0
| return null;
|
755 |
| } |
756 |
| } |
757 |
| |
758 |
| |
759 |
| |
760 |
| |
761 |
| |
762 |
| |
763 |
| |
764 |
0
| public boolean isReadOnly() {
|
765 |
0
| return readOnly;
|
766 |
| } |
767 |
| |
768 |
| |
769 |
| |
770 |
| |
771 |
| |
772 |
| |
773 |
| |
774 |
| |
775 |
1145
| public Configuration add(String name) throws ReadOnlyException {
|
776 |
1145
| if (readOnly) {
|
777 |
2
| throw new ReadOnlyException();
|
778 |
| } |
779 |
| |
780 |
1143
| Element elem = config.getOwnerDocument().createElement(name);
|
781 |
1143
| config.appendChild(elem);
|
782 |
1143
| setDirty();
|
783 |
1143
| return new Configuration(this, elem, readOnly);
|
784 |
| } |
785 |
| |
786 |
| |
787 |
| |
788 |
| |
789 |
| |
790 |
| |
791 |
| |
792 |
| |
793 |
| |
794 |
| |
795 |
1177
| public void add(Configuration newConfig) throws ReadOnlyException {
|
796 |
1177
| if (readOnly) {
|
797 |
0
| throw new ReadOnlyException();
|
798 |
| } |
799 |
| |
800 |
1177
| Node imported = config.getOwnerDocument().importNode(newConfig.config, true);
|
801 |
1177
| config.appendChild(imported);
|
802 |
1177
| newConfig.config = (Element) imported;
|
803 |
1177
| newConfig.root = this;
|
804 |
1177
| setDirty();
|
805 |
| } |
806 |
| |
807 |
| |
808 |
| |
809 |
| |
810 |
| |
811 |
| |
812 |
1179
| public void delete() throws ReadOnlyException {
|
813 |
1179
| if (readOnly) {
|
814 |
0
| throw new ReadOnlyException();
|
815 |
| } |
816 |
| |
817 |
1179
| if (config.getParentNode() != null) {
|
818 |
1179
| config.getParentNode().removeChild(config);
|
819 |
| } |
820 |
1179
| setDirty();
|
821 |
| } |
822 |
| |
823 |
| |
824 |
| |
825 |
| |
826 |
| |
827 |
| |
828 |
| |
829 |
0
| public void removeAttribute(String name) throws ReadOnlyException {
|
830 |
0
| if (readOnly) {
|
831 |
0
| throw new ReadOnlyException();
|
832 |
| } |
833 |
| |
834 |
0
| config.removeAttribute(name);
|
835 |
0
| setDirty();
|
836 |
| } |
837 |
| |
838 |
| |
839 |
| |
840 |
| |
841 |
| |
842 |
| |
843 |
| |
844 |
| |
845 |
28
| public void setAttribute(String name, String value) throws ReadOnlyException {
|
846 |
28
| if (readOnly) {
|
847 |
1
| throw new ReadOnlyException();
|
848 |
| } |
849 |
| |
850 |
27
| config.setAttribute(name, value);
|
851 |
27
| setDirty();
|
852 |
| } |
853 |
| |
854 |
| |
855 |
| |
856 |
| |
857 |
| |
858 |
| |
859 |
| |
860 |
| |
861 |
0
| public void setAttribute(String name, boolean value) throws ReadOnlyException {
|
862 |
0
| setAttribute(name, String.valueOf(value));
|
863 |
| } |
864 |
| |
865 |
| |
866 |
| |
867 |
| |
868 |
| |
869 |
| |
870 |
| |
871 |
| |
872 |
2
| public void setAttribute(String name, int value) throws ReadOnlyException {
|
873 |
2
| setAttribute(name, String.valueOf(value));
|
874 |
| } |
875 |
| |
876 |
| |
877 |
| |
878 |
| |
879 |
| |
880 |
| |
881 |
| |
882 |
| |
883 |
0
| public void setAttribute(String name, short value) throws ReadOnlyException {
|
884 |
0
| setAttribute(name, String.valueOf(value));
|
885 |
| } |
886 |
| |
887 |
| |
888 |
| |
889 |
| |
890 |
| |
891 |
| |
892 |
| |
893 |
| |
894 |
0
| public void setAttribute(String name, long value) throws ReadOnlyException {
|
895 |
0
| setAttribute(name, String.valueOf(value));
|
896 |
| } |
897 |
| |
898 |
| |
899 |
| |
900 |
| |
901 |
| |
902 |
| |
903 |
| |
904 |
| |
905 |
0
| public void setAttribute(String name, float value) throws ReadOnlyException {
|
906 |
0
| setAttribute(name, String.valueOf(value));
|
907 |
| } |
908 |
| |
909 |
| |
910 |
| |
911 |
| |
912 |
| |
913 |
| |
914 |
| |
915 |
| |
916 |
0
| public void setAttribute(String name, double value) throws ReadOnlyException {
|
917 |
0
| setAttribute(name, String.valueOf(value));
|
918 |
| } |
919 |
| |
920 |
| |
921 |
| |
922 |
| |
923 |
| |
924 |
| |
925 |
| |
926 |
| |
927 |
0
| public void setAttribute(String name, byte value) throws ReadOnlyException {
|
928 |
0
| setAttribute(name, String.valueOf(value));
|
929 |
| } |
930 |
| |
931 |
| |
932 |
| |
933 |
| |
934 |
| |
935 |
| |
936 |
| |
937 |
| |
938 |
0
| public void setAttribute(String name, char value) throws ReadOnlyException {
|
939 |
0
| setAttribute(name, String.valueOf(value));
|
940 |
| } |
941 |
| |
942 |
| |
943 |
| |
944 |
| |
945 |
| |
946 |
| |
947 |
| |
948 |
0
| public void setValue(String value) throws ReadOnlyException {
|
949 |
0
| if (readOnly) {
|
950 |
0
| throw new ReadOnlyException();
|
951 |
| } |
952 |
| |
953 |
0
| NodeList list = config.getChildNodes();
|
954 |
0
| if (list.getLength() == 1 && list.item(0).getNodeType() == Node.TEXT_NODE) {
|
955 |
0
| list.item(0).setNodeValue(value);
|
956 |
| } else { |
957 |
0
| Text text = config.getOwnerDocument().createTextNode(value);
|
958 |
0
| config.appendChild(text);
|
959 |
| } |
960 |
0
| setDirty();
|
961 |
| } |
962 |
| |
963 |
| |
964 |
| |
965 |
| |
966 |
| |
967 |
| |
968 |
| |
969 |
0
| public void setValue(boolean value) throws ReadOnlyException {
|
970 |
0
| setValue(String.valueOf(value));
|
971 |
| } |
972 |
| |
973 |
| |
974 |
| |
975 |
| |
976 |
| |
977 |
| |
978 |
| |
979 |
0
| public void setValue(int value) throws ReadOnlyException {
|
980 |
0
| setValue(String.valueOf(value));
|
981 |
| } |
982 |
| |
983 |
| |
984 |
| |
985 |
| |
986 |
| |
987 |
| |
988 |
| |
989 |
0
| public void setValue(short value) throws ReadOnlyException {
|
990 |
0
| setValue(String.valueOf(value));
|
991 |
| } |
992 |
| |
993 |
| |
994 |
| |
995 |
| |
996 |
| |
997 |
| |
998 |
| |
999 |
0
| public void setValue(long value) throws ReadOnlyException {
|
1000 |
0
| setValue(String.valueOf(value));
|
1001 |
| } |
1002 |
| |
1003 |
| |
1004 |
| |
1005 |
| |
1006 |
| |
1007 |
| |
1008 |
| |
1009 |
0
| public void setValue(float value) throws ReadOnlyException {
|
1010 |
0
| setValue(String.valueOf(value));
|
1011 |
| } |
1012 |
| |
1013 |
| |
1014 |
| |
1015 |
| |
1016 |
| |
1017 |
| |
1018 |
| |
1019 |
0
| public void setValue(double value) throws ReadOnlyException {
|
1020 |
0
| setValue(String.valueOf(value));
|
1021 |
| } |
1022 |
| |
1023 |
| |
1024 |
| |
1025 |
| |
1026 |
| |
1027 |
| |
1028 |
| |
1029 |
0
| public void setValue(byte value) throws ReadOnlyException {
|
1030 |
0
| setValue(String.valueOf(value));
|
1031 |
| } |
1032 |
| |
1033 |
| |
1034 |
| |
1035 |
| |
1036 |
| |
1037 |
| |
1038 |
| |
1039 |
0
| public void setValue(char value) throws ReadOnlyException {
|
1040 |
0
| setValue(String.valueOf(value));
|
1041 |
| } |
1042 |
| } |