View Javadoc

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