001/* 002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 003 * 004 * This software is open source. 005 * See the bottom of this file for the licence. 006 * 007 * $Id: Attribute.java,v 1.4 2001/03/01 23:07:46 jstrachan Exp $ 008 */ 009 010package org.dom4j; 011 012/**<p><code>Attribute</code> defines an XML attribute. 013 * An attribute may have a name, an optional namespace and a value.</p> 014 * 015 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> 016 * @version $Revision: 1.4 $ 017 */ 018public interface Attribute extends Node { 019 020 /** <p>Returns the <code>QName</code> of this attribute which represents 021 * the local name, the qualified name and the <code>Namespace</code>.</p> 022 * 023 * @return the <code>QName</code> associated with this attribute 024 */ 025 public QName getQName(); 026 027 /** <p>Returns the <code>Namespace</code> of this element if one exists 028 * otherwise null is returned returned.</p> 029 * 030 * @return the <code>Namespace</code> associated with this node 031 */ 032 public Namespace getNamespace(); 033 034 /** <p>Sets the <code>Namespace</code> of this element or if this element 035 * is read only then an <code>UnsupportedOperationException</code> 036 * is thrown.</p> 037 * 038 * @param namespace is the <code>Namespace</code> to associate with this 039 * element 040 */ 041 public void setNamespace(Namespace namespace); 042 043 /** <p>Returns the namespace prefix of this element if one exists 044 * otherwise an empty <code>String</code> is returned.</p> 045 * 046 * @return the prefix of the <code>Namespace</code> of this element 047 * or an empty <code>String</code> 048 */ 049 public String getNamespacePrefix(); 050 051 /** <p>Returns the URI mapped to the namespace of this element 052 * if one exists otherwise an empty <code>String</code> is returned.</p> 053 * 054 * @return the URI for the <code>Namespace</code> of this element 055 * or an empty <code>String</code> 056 */ 057 public String getNamespaceURI(); 058 059 /** <p>Returns the fully qualified name of this element. 060 * This will be the same as the value returned from {@link #getName} 061 * if this element has no namespace attached to this element or an 062 * expression of the form 063 * <pre> 064 * getNamespacePrefix() + ":" + getName() 065 * </pre> 066 * will be returned. 067 * 068 * @return the fully qualified name of the element. 069 */ 070 public String getQualifiedName(); 071 072 /** <p>Returns the value of the attribute. This method 073 * returns the same value as the {@link #getText} method. 074 * 075 * @return the value of the attribute. 076 */ 077 public String getValue(); 078 079 /** <p>Sets the value of this attribute or this method will 080 * throw an <code>UnsupportedOperationException</code> if it is 081 * read-only.</p> 082 * 083 * @param value is the new value of this attribute 084 */ 085 public void setValue(String value); 086 087 /** Accesses the data of this attribute which may implement data typing 088 * bindings such as XML Schema or 089 * Java Bean bindings or will return the same value as {@link #getText} 090 */ 091 public Object getData(); 092 093 /** Sets the data value of this attribute if this element supports data 094 * binding or calls {@link #setText} if it doesn't 095 */ 096 public void setData(Object data); 097 098} 099 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://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 (C) MetaStuff, Ltd. All Rights Reserved. 144 * 145 * $Id: Attribute.java,v 1.4 2001/03/01 23:07:46 jstrachan Exp $ 146 */