Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 1,042   Methods: 79
NCLOC: 455   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Configuration.java 64.1% 50.7% 40.5% 50.9%
coverage coverage
 1    /*
 2    * Licensed to the Apache Software Foundation (ASF) under one or more
 3    * contributor license agreements. See the NOTICE file distributed with
 4    * this work for additional information regarding copyright ownership.
 5    * The ASF licenses this file to You under the Apache License, Version 2.0
 6    * (the "License"); you may not use this file except in compliance with
 7    * the License. You may obtain a copy of the License at
 8    *
 9    * http://www.apache.org/licenses/LICENSE-2.0
 10    *
 11    * Unless required by applicable law or agreed to in writing, software
 12    * distributed under the License is distributed on an "AS IS" BASIS,
 13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14    * See the License for the specific language governing permissions and
 15    * limitations under the License.
 16    *
 17    * $Id: Configuration.java 541508 2007-05-25 01:54:12Z vgritsenko $
 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    * Configuration is a utility class that allows Configurable objects to
 38    * easily manage configuration information in a simple and consistent
 39    * fashion.
 40    *
 41    * @see org.apache.xindice.util.Configurable
 42    * @version $Revision: 541508 $, $Date: 2007-05-24 18:54:12 -0700 (Thu, 24 May 2007) $
 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    * Create read only configuration out of Element
 67    * @param config Configuration element
 68    */
 69  288 public Configuration(Element config) {
 70  288 this(config, true);
 71    }
 72   
 73    /**
 74    * Create read only configuration out of Document
 75    * @param config Configuration document
 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    // Only call on root configuration will actually reset dirty flag
 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    * getElement returns the Element being managed by this Configuration.
 110    *
 111    * Returned Element should not be modified, use Configuration's methods
 112    * to modify managed Element.
 113    *
 114    * @return The Configuration Element
 115    * @throws ReadOnlyException If the Configuration is Read-only
 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    * getName returns the name of the Configuration node.
 126    *
 127    * @return The Node name
 128    */
 129  1235 public String getName() {
 130  1235 return config.getNodeName();
 131    }
 132   
 133    /**
 134    * hasAttributes returns whether or not the Configuration node has any
 135    * attributes associated with it.
 136    *
 137    * @return Whether or not attributes exist
 138    */
 139  17 public boolean hasAttributes() {
 140  17 return config.getAttributes().getLength() > 0;
 141    }
 142   
 143    /**
 144    * getAttribute returns an attribute from the Configuration node.
 145    *
 146    * @param name The attribute name
 147    * @param defValue The default value
 148    * @return The attribute value
 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    * getAttribute returns an attribute from the Configuration node.
 160    *
 161    * @param name The attribute name
 162    * @return The attribute value
 163    */
 164  7254 public String getAttribute(String name) {
 165  7254 return getAttribute(name, "");
 166    }
 167   
 168    /**
 169    * getBooleanAttribute returns an attribute from the Configuration node.
 170    *
 171    * @param name The attribute name
 172    * @param defValue The default value
 173    * @return The attribute value
 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    * getBooleanAttribute returns an attribute from the Configuration node.
 186    *
 187    * @param name The attribute name
 188    * @return The attribute value
 189    */
 190  1 public boolean getBooleanAttribute(String name) {
 191  1 return getBooleanAttribute(name, false);
 192    }
 193   
 194    /**
 195    * getIntAttribute returns an attribute from the Configuration node.
 196    *
 197    * @param name The attribute name
 198    * @param defValue The default value
 199    * @return The attribute value
 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    * getIntAttribute returns an attribute from the Configuration node.
 211    *
 212    * @param name The attribute name
 213    * @return The attribute value
 214    */
 215  1 public int getIntAttribute(String name) {
 216  1 return getIntAttribute(name, 0);
 217    }
 218   
 219    /**
 220    * getShortAttribute returns an attribute from the Configuration node.
 221    *
 222    * @param name The attribute name
 223    * @param defValue The default value
 224    * @return The attribute value
 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    * getShortAttribute returns an attribute from the Configuration node.
 236    *
 237    * @param name The attribute name
 238    * @return The attribute value
 239    */
 240  0 public short getShortAttribute(String name) {
 241  0 return getShortAttribute(name, (short) 0);
 242    }
 243   
 244    /**
 245    * getLongAttribute returns an attribute from the Configuration node.
 246    *
 247    * @param name The attribute name
 248    * @param defValue The default value
 249    * @return The attribute value
 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    * getLongAttribute returns an attribute from the Configuration node.
 261    *
 262    * @param name The attribute name
 263    * @return The attribute value
 264    */
 265  0 public long getLongAttribute(String name) {
 266  0 return getLongAttribute(name, (long) 0);
 267    }
 268   
 269    /**
 270    * getFloatAttribute returns an attribute from the Configuration node.
 271    *
 272    * @param name The attribute name
 273    * @param defValue The default value
 274    * @return The attribute value
 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    * getFloatAttribute returns an attribute from the Configuration node.
 286    *
 287    * @param name The attribute name
 288    * @return The attribute value
 289    */
 290  0 public float getFloatAttribute(String name) {
 291  0 return getFloatAttribute(name, (float) 0.0);
 292    }
 293   
 294    /**
 295    * getDoubleAttribute returns an attribute from the Configuration node.
 296    *
 297    * @param name The attribute name
 298    * @param defValue The default value
 299    * @return The attribute value
 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    * getDoubleAttribute returns an attribute from the Configuration node.
 311    *
 312    * @param name The attribute name
 313    * @return The attribute value
 314    */
 315  0 public double getDoubleAttribute(String name) {
 316  0 return getDoubleAttribute(name, 0.0D);
 317    }
 318   
 319    /**
 320    * getByteAttribute returns an attribute from the Configuration node.
 321    *
 322    * @param name The attribute name
 323    * @param defValue The default value
 324    * @return The attribute value
 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    * getByteAttribute returns an attribute from the Configuration node.
 336    *
 337    * @param name The attribute name
 338    * @return The attribute value
 339    */
 340  0 public byte getByteAttribute(String name) {
 341  0 return getByteAttribute(name, (byte) 0);
 342    }
 343   
 344    /**
 345    * getCharAttribute returns an attribute from the Configuration node.
 346    *
 347    * @param name The attribute name
 348    * @param defValue The default value
 349    * @return The attribute value
 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    * getCharAttribute returns an attribute from the Configuration node.
 361    *
 362    * @param name The attribute name
 363    * @return The attribute value
 364    */
 365  0 public char getCharAttribute(String name) {
 366  0 return getCharAttribute(name, '\0');
 367    }
 368   
 369    /**
 370    * listAttributes returns a list of the attribute names that exist for
 371    * this Configuration node.
 372    *
 373    * @return The Attribute names
 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    * hasValue returns whether or not the Configuration node has a textual
 387    * value associated with it.
 388    *
 389    * @return Whether or not the node has a text value
 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    * getValue returns the value from the Configuration node.
 398    *
 399    * @param defValue The default value
 400    * @return The value
 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    * getValue returns the value from the Configuration node.
 413    *
 414    * @return The value
 415    */
 416  0 public String getValue() {
 417  0 return getValue("");
 418    }
 419   
 420    /**
 421    * getBooleanValue returns the value from the Configuration node.
 422    *
 423    * @param defValue The default value
 424    * @return The value
 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    * getBooleanValue returns the value from the Configuration node.
 436    *
 437    * @return The value
 438    */
 439  0 public boolean getBooleanValue() {
 440  0 return getBooleanValue(false);
 441    }
 442   
 443    /**
 444    * getIntValue returns the value from the Configuration node.
 445    *
 446    * @param defValue The default value
 447    * @return The value
 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    * getIntValue returns the value from the Configuration node.
 459    *
 460    * @return The value
 461    */
 462  0 public int getIntValue() {
 463  0 return getIntValue(0);
 464    }
 465   
 466    /**
 467    * getShortValue returns the value from the Configuration node.
 468    *
 469    * @param defValue The default value
 470    * @return The value
 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    * getShortValue returns the value from the Configuration node.
 482    *
 483    * @return The value
 484    */
 485  0 public short getShortValue() {
 486  0 return getShortValue((short) 0);
 487    }
 488   
 489    /**
 490    * getLongValue returns the value from the Configuration node.
 491    *
 492    * @param defValue The default value
 493    * @return The value
 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    * getLongValue returns the value from the Configuration node.
 505    *
 506    * @return The value
 507    */
 508  0 public long getLongValue() {
 509  0 return getLongValue(0);
 510    }
 511   
 512    /**
 513    * getFloatValue returns the value from the Configuration node.
 514    *
 515    * @param defValue The default value
 516    * @return The value
 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    * getFloatValue returns the value from the Configuration node.
 528    *
 529    * @return The value
 530    */
 531  0 public float getFloatValue() {
 532  0 return getFloatValue((float) 0.0);
 533    }
 534   
 535    /**
 536    * getDoubleValue returns the value from the Configuration node.
 537    *
 538    * @param defValue The default value
 539    * @return The value
 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    * getDoubleValue returns the value from the Configuration node.
 551    *
 552    * @return The value
 553    */
 554  0 public double getDoubleValue() {
 555  0 return getDoubleValue(0.0D);
 556    }
 557   
 558    /**
 559    * getByteValue returns the value from the Configuration node.
 560    *
 561    * @param defValue The default value
 562    * @return The value
 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    * getByteValue returns the value from the Configuration node.
 574    *
 575    * @return The value
 576    */
 577  0 public byte getByteValue() {
 578  0 return getByteValue((byte) 0);
 579    }
 580   
 581    /**
 582    * getCharValue returns the value from the Configuration node.
 583    *
 584    * @param defValue The default value
 585    * @return The value
 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    * getCharValue returns the value from the Configuration node.
 597    *
 598    * @return The value
 599    */
 600  0 public char getCharValue() {
 601  0 return getCharValue('\0');
 602    }
 603   
 604    /**
 605    * hasChildren returns whether or not the Configuration node has child
 606    * Configuration elements.
 607    *
 608    * @return Whether or not children exist
 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    * getChildren returns the child Configuration nodes for this Configuration
 624    * node.
 625    *
 626    * @return The children
 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    * processChildren runs through the children of this Configuration and
 643    * performs prcessing callbacks to the ConfigurationCallback object.
 644    *
 645    * @param callback The callback object
 646    */
 647  0 public void processChildren(ConfigurationCallback callback) {
 648  0 NodeList list = config.getChildNodes();
 649   
 650    // Copy node list into array since callback can alter the configuration
 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    * processChildren runs through the children of this Configuration and
 672    * performs prcessing callbacks to the ConfigurationCallback object.
 673    *
 674    * @param callback The callback object
 675    * @param name The Configuration name to process
 676    */
 677  3068 public void processChildren(String name, ConfigurationCallback callback) {
 678  3068 NodeList list = config.getChildNodes();
 679   
 680    // Copy node list into array since callback can alter the configuration
 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    * getChildren returns all children Configuration nodes that matches the
 702    * specified name.
 703    *
 704    * @param name The Configuration node name
 705    * @return Children Configuration
 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    * getChild returns the first child Configuration node that matches the
 723    * specified name.
 724    *
 725    * @param name The Configuration node name
 726    * @param create Create Configuration if it doesn't exist
 727    * @return The child Configuration
 728    * @throws ReadOnlyException if the Configuration is read-only
 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    * getChild returns the first child Configuration node that matches the
 745    * specified name.
 746    *
 747    * @param name The Configuration node name
 748    * @return The child Configuration
 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    * isReadOnly returns whether or not this Configuration node is a
 760    * read-only node.
 761    *
 762    * @return The read-only status
 763    */
 764  0 public boolean isReadOnly() {
 765  0 return readOnly;
 766    }
 767   
 768    /**
 769    * add adds a new Configuration node to this Configuration node.
 770    *
 771    * @param name The name of the Configuration node
 772    * @return The new Configuration node
 773    * @throws ReadOnlyException if the Configuration is read-only
 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    * add adds an existing Configuration node to this Configuration node.
 788    *
 789    * <strong>NOTE:</strong> This method does NOT perform a deep copy on the
 790    * DOM Node that newConfig manages.
 791    *
 792    * @param newConfig The Configuration node to add
 793    * @throws ReadOnlyException if the Configuration is read-only
 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    * delete deletes this Configuration node from its parent Configuration.
 809    *
 810    * @throws ReadOnlyException if the Configuration is read-only
 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    * removeAttribute removes the named attribute from this Configuration.
 825    *
 826    * @param name The attribute name
 827    * @throws ReadOnlyException if the Configuration is read-only
 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    * setAttribute sets the attribute value for this Configuration.
 840    *
 841    * @param name The attribute name
 842    * @param value The attribute value
 843    * @throws ReadOnlyException if the Configuration is read-only
 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    * setAttribute sets the attribute value for this Configuration.
 856    *
 857    * @param name The attribute name
 858    * @param value The attribute value
 859    * @throws ReadOnlyException if the Configuration is read-only
 860    */
 861  0 public void setAttribute(String name, boolean value) throws ReadOnlyException {
 862  0 setAttribute(name, String.valueOf(value));
 863    }
 864   
 865    /**
 866    * setAttribute sets the attribute value for this Configuration.
 867    *
 868    * @param name The attribute name
 869    * @param value The attribute value
 870    * @throws ReadOnlyException if the Configuration is read-only
 871    */
 872  2 public void setAttribute(String name, int value) throws ReadOnlyException {
 873  2 setAttribute(name, String.valueOf(value));
 874    }
 875   
 876    /**
 877    * setAttribute sets the attribute value for this Configuration.
 878    *
 879    * @param name The attribute name
 880    * @param value The attribute value
 881    * @throws ReadOnlyException if the Configuration is read-only
 882    */
 883  0 public void setAttribute(String name, short value) throws ReadOnlyException {
 884  0 setAttribute(name, String.valueOf(value));
 885    }
 886   
 887    /**
 888    * setAttribute sets the attribute value for this Configuration.
 889    *
 890    * @param name The attribute name
 891    * @param value The attribute value
 892    * @throws ReadOnlyException if the Configuration is read-only
 893    */
 894  0 public void setAttribute(String name, long value) throws ReadOnlyException {
 895  0 setAttribute(name, String.valueOf(value));
 896    }
 897   
 898    /**
 899    * setAttribute sets the attribute value for this Configuration.
 900    *
 901    * @param name The attribute name
 902    * @param value The attribute value
 903    * @throws ReadOnlyException if the Configuration is read-only
 904    */
 905  0 public void setAttribute(String name, float value) throws ReadOnlyException {
 906  0 setAttribute(name, String.valueOf(value));
 907    }
 908   
 909    /**
 910    * setAttribute sets the attribute value for this Configuration.
 911    *
 912    * @param name The attribute name
 913    * @param value The attribute value
 914    * @throws ReadOnlyException if the Configuration is read-only
 915    */
 916  0 public void setAttribute(String name, double value) throws ReadOnlyException {
 917  0 setAttribute(name, String.valueOf(value));
 918    }
 919   
 920    /**
 921    * setAttribute sets the attribute value for this Configuration.
 922    *
 923    * @param name The attribute name
 924    * @param value The attribute value
 925    * @throws ReadOnlyException if the Configuration is read-only
 926    */
 927  0 public void setAttribute(String name, byte value) throws ReadOnlyException {
 928  0 setAttribute(name, String.valueOf(value));
 929    }
 930   
 931    /**
 932    * setAttribute sets the attribute value for this Configuration.
 933    *
 934    * @param name The attribute name
 935    * @param value The attribute value
 936    * @throws ReadOnlyException if the Configuration is read-only
 937    */
 938  0 public void setAttribute(String name, char value) throws ReadOnlyException {
 939  0 setAttribute(name, String.valueOf(value));
 940    }
 941   
 942    /**
 943    * setValue sets the value of the Configuration node.
 944    *
 945    * @param value The New Value
 946    * @throws ReadOnlyException if the Configuration is read-only
 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    * setValue sets the value of the Configuration node.
 965    *
 966    * @param value The New Value
 967    * @throws ReadOnlyException if the Configuration is read-only
 968    */
 969  0 public void setValue(boolean value) throws ReadOnlyException {
 970  0 setValue(String.valueOf(value));
 971    }
 972   
 973    /**
 974    * setValue sets the value of the Configuration node.
 975    *
 976    * @param value The New Value
 977    * @throws ReadOnlyException if the Configuration is read-only
 978    */
 979  0 public void setValue(int value) throws ReadOnlyException {
 980  0 setValue(String.valueOf(value));
 981    }
 982   
 983    /**
 984    * setValue sets the value of the Configuration node.
 985    *
 986    * @param value The New Value
 987    * @throws ReadOnlyException if the Configuration is read-only
 988    */
 989  0 public void setValue(short value) throws ReadOnlyException {
 990  0 setValue(String.valueOf(value));
 991    }
 992   
 993    /**
 994    * setValue sets the value of the Configuration node.
 995    *
 996    * @param value The New Value
 997    * @throws ReadOnlyException if the Configuration is read-only
 998    */
 999  0 public void setValue(long value) throws ReadOnlyException {
 1000  0 setValue(String.valueOf(value));
 1001    }
 1002   
 1003    /**
 1004    * setValue sets the value of the Configuration node.
 1005    *
 1006    * @param value The New Value
 1007    * @throws ReadOnlyException if the Configuration is read-only
 1008    */
 1009  0 public void setValue(float value) throws ReadOnlyException {
 1010  0 setValue(String.valueOf(value));
 1011    }
 1012   
 1013    /**
 1014    * setValue sets the value of the Configuration node.
 1015    *
 1016    * @param value The New Value
 1017    * @throws ReadOnlyException if the Configuration is read-only
 1018    */
 1019  0 public void setValue(double value) throws ReadOnlyException {
 1020  0 setValue(String.valueOf(value));
 1021    }
 1022   
 1023    /**
 1024    * setValue sets the value of the Configuration node.
 1025    *
 1026    * @param value The New Value
 1027    * @throws ReadOnlyException if the Configuration is read-only
 1028    */
 1029  0 public void setValue(byte value) throws ReadOnlyException {
 1030  0 setValue(String.valueOf(value));
 1031    }
 1032   
 1033    /**
 1034    * setValue sets the value of the Configuration node.
 1035    *
 1036    * @param value The New Value
 1037    * @throws ReadOnlyException if the Configuration is read-only
 1038    */
 1039  0 public void setValue(char value) throws ReadOnlyException {
 1040  0 setValue(String.valueOf(value));
 1041    }
 1042    }