View Javadoc

    1   /*
    2    * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
    3    *
    4    * This software is open source.
    5    * See the bottom of this file for the licence.
    6    */
    7
    8   package org.dom4j;
    9
    10  /***
    11   * <p>
    12   * <code>Attribute</code> defines an XML attribute. An attribute may have a
    13   * name, an optional namespace and a value.
    14   * </p>
    15   *
    16   * @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a>
    17   * @version $Revision: 1.9 $
    18   */
    19  public interface Attribute extends Node {
    20      /***
    21       * <p>
    22       * Returns the <code>QName</code> of this attribute which represents the
    23       * local name, the qualified name and the <code>Namespace</code>.
    24       * </p>
    25       *
    26       * @return the <code>QName</code> associated with this attribute
    27       */
    28      QName getQName();
    29
    30      /***
    31       * <p>
    32       * Returns the <code>Namespace</code> of this element if one exists
    33       * otherwise null is returned returned.
    34       * </p>
    35       *
    36       * @return the <code>Namespace</code> associated with this node
    37       */
    38      Namespace getNamespace();
    39
    40      /***
    41       * <p>
    42       * Sets the <code>Namespace</code> of this element or if this element is
    43       * read only then an <code>UnsupportedOperationException</code> is thrown.
    44       * </p>
    45       *
    46       * @param namespace
    47       *            is the <code>Namespace</code> to associate with this element
    48       */
    49      void setNamespace(Namespace namespace);
    50
    51      /***
    52       * <p>
    53       * Returns the namespace prefix of this element if one exists otherwise an
    54       * empty <code>String</code> is returned.
    55       * </p>
    56       *
    57       * @return the prefix of the <code>Namespace</code> of this element or an
    58       *         empty <code>String</code>
    59       */
    60      String getNamespacePrefix();
    61
    62      /***
    63       * <p>
    64       * Returns the URI mapped to the namespace of this element if one exists
    65       * otherwise an empty <code>String</code> is returned.
    66       * </p>
    67       *
    68       * @return the URI for the <code>Namespace</code> of this element or an
    69       *         empty <code>String</code>
    70       */
    71      String getNamespaceURI();
    72
    73      /***
    74       * <p>
    75       * Returns the fully qualified name of this element.
    76       * </p>
    77       *
    78       * <p>
    79       * This will be the same as the value returned from {@link Node#getName()}
    80       * if this element has no namespace attached to this element or an
    81       * expression of the form
    82       *
    83       * <pre>
    84       * getNamespacePrefix() + &quot;:&quot; + getName()
    85       * </pre>
    86       *
    87       * will be returned.
    88       * </p>
    89       *
    90       * @return the fully qualified name of the element
    91       */
    92      String getQualifiedName();
    93
    94      /***
    95       * <p>
    96       * Returns the value of the attribute. This method returns the same value as
    97       * the {@link Node#getText()}method.
    98       * </p>
    99       *
    100      * @return the value of the attribute
    101      */
    102     String getValue();
    103
    104     /***
    105      * <p>
    106      * Sets the value of this attribute or this method will throw an
    107      * <code>UnsupportedOperationException</code> if it is read-only.
    108      * </p>
    109      *
    110      * @param value
    111      *            is the new value of this attribute
    112      */
    113     void setValue(String value);
    114
    115     /***
    116      * <p>
    117      * Accesses the data of this attribute which may implement data typing
    118      * bindings such as <code>XML Schema</code> or <code>Java Bean</code>
    119      * bindings or will return the same value as {@link Node#getText()}.
    120      * </p>
    121      *
    122      * @return the attribute data
    123      */
    124     Object getData();
    125
    126     /***
    127      * <p>
    128      * Sets the data value of this attribute if this element supports data
    129      * binding or calls {@link Node#setText(String)}if it doesn't.
    130      * </p>
    131      *
    132      * @param data
    133      *            the attribute data
    134      */
    135     void setData(Object data);
    136 }
    137
    138 /*
    139  * Redistribution and use of this software and associated documentation
    140  * ("Software"), with or without modification, are permitted provided that the
    141  * following conditions are met:
    142  *
    143  * 1. Redistributions of source code must retain copyright statements and
    144  * notices. Redistributions must also contain a copy of this document.
    145  *
    146  * 2. Redistributions in binary form must reproduce the above copyright notice,
    147  * this list of conditions and the following disclaimer in the documentation
    148  * and/or other materials provided with the distribution.
    149  *
    150  * 3. The name "DOM4J" must not be used to endorse or promote products derived
    151  * from this Software without prior written permission of MetaStuff, Ltd. For
    152  * written permission, please contact dom4j-info@metastuff.com.
    153  *
    154  * 4. Products derived from this Software may not be called "DOM4J" nor may
    155  * "DOM4J" appear in their names without prior written permission of MetaStuff,
    156  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
    157  *
    158  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
    159  *
    160  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
    161  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    162  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    163  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
    164  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    165  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    166  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    167  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    168  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    169  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    170  * POSSIBILITY OF SUCH DAMAGE.
    171  *
    172  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
    173  */