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: DefaultAttribute.java,v 1.7 2001/06/20 18:59:23 jstrachan Exp $
008 */
009
010package org.dom4j.tree;
011
012import org.dom4j.Element;
013import org.dom4j.QName;
014import org.dom4j.Namespace;
015
016/** <p><code>DefaultAttribute</code> implements a doubly linked node which 
017  * supports the parent relationship and is mutable.</p>
018  *
019  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
020  * @version $Revision: 1.7 $
021  */
022public class DefaultAttribute extends FlyweightAttribute {
023
024    /** The parent of this node */
025    private Element parent;
026
027    
028    public DefaultAttribute(QName qname) { 
029        super(qname);
030    }
031    
032    public DefaultAttribute(QName qname,String value) { 
033        super(qname, value);
034    }
035    
036    public DefaultAttribute(Element parent,QName qname,String value) { 
037        super(qname, value);
038        this.parent = parent;
039    }
040    
041    /** Creates the <code>Attribute</code> with the specified local name
042      * and value.
043      *
044      * @param name is the name of the attribute
045      * @param value is the value of the attribute
046      */
047    public DefaultAttribute(String name,String value) {
048        super(name, value);
049    }
050    
051    /** Creates the <code>Attribute</code> with the specified local name,
052      * value and <code>Namespace</code>.
053      *
054      * @param name is the name of the attribute
055      * @param value is the value of the attribute
056      * @param namespace is the namespace of the attribute
057      */
058    public DefaultAttribute(String name,String value,Namespace namespace) {
059        super(name, value, namespace);
060    }
061    
062    /** Creates the <code>Attribute</code> with the specified local name,
063      * value and <code>Namespace</code>.
064      *
065      * @param parent is the parent element
066      * @param name is the name of the attribute
067      * @param value is the value of the attribute
068      * @param namespace is the namespace of the attribute
069      */
070    public DefaultAttribute(Element parent,String name,String value,Namespace namespace) {
071        super(name, value, namespace);
072        this.parent = parent;
073    }
074
075    public void setValue(String value) {
076        this.value = value;
077    }
078    
079    public Element getParent() {
080        return parent;
081    }
082
083    public void setParent(Element parent) {
084        this.parent = parent;
085    }
086    
087    public boolean supportsParent() {
088        return true;
089    }
090    
091    public boolean isReadOnly() {
092        return false;
093    }
094
095}
096
097
098
099
100/*
101 * Redistribution and use of this software and associated documentation
102 * ("Software"), with or without modification, are permitted provided
103 * that the following conditions are met:
104 *
105 * 1. Redistributions of source code must retain copyright
106 *    statements and notices.  Redistributions must also contain a
107 *    copy of this document.
108 *
109 * 2. Redistributions in binary form must reproduce the
110 *    above copyright notice, this list of conditions and the
111 *    following disclaimer in the documentation and/or other
112 *    materials provided with the distribution.
113 *
114 * 3. The name "DOM4J" must not be used to endorse or promote
115 *    products derived from this Software without prior written
116 *    permission of MetaStuff, Ltd.  For written permission,
117 *    please contact dom4j-info@metastuff.com.
118 *
119 * 4. Products derived from this Software may not be called "DOM4J"
120 *    nor may "DOM4J" appear in their names without prior written
121 *    permission of MetaStuff, Ltd. DOM4J is a registered
122 *    trademark of MetaStuff, Ltd.
123 *
124 * 5. Due credit should be given to the DOM4J Project
125 *    (http://dom4j.org/).
126 *
127 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
128 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
129 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
130 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
131 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
132 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
133 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
134 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
135 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
136 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
137 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
138 * OF THE POSSIBILITY OF SUCH DAMAGE.
139 *
140 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
141 *
142 * $Id: DefaultAttribute.java,v 1.7 2001/06/20 18:59:23 jstrachan Exp $
143 */