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: DefaultAttribute.java,v 1.11 2004/06/25 08:03:41 maartenc Exp $
8    */
9   
10  package org.dom4j.tree;
11  
12  import org.dom4j.Element;
13  import org.dom4j.Namespace;
14  import org.dom4j.QName;
15  
16  /*** <p><code>DefaultAttribute</code> implements a doubly linked node which 
17    * supports the parent relationship and is mutable.</p>
18    *
19    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
20    * @version $Revision: 1.11 $
21    */
22  public class DefaultAttribute extends FlyweightAttribute {
23  
24      /*** The parent of this node */
25      private Element parent;
26  
27      
28      public DefaultAttribute(QName qname) { 
29          super(qname);
30      }
31      
32      public DefaultAttribute(QName qname,String value) { 
33          super(qname, value);
34      }
35      
36      public DefaultAttribute(Element parent,QName qname,String value) { 
37          super(qname, value);
38          this.parent = parent;
39      }
40      
41      /*** Creates the <code>Attribute</code> with the specified local name
42        * and value.
43        *
44        * @param name is the name of the attribute
45        * @param value is the value of the attribute
46        */
47      public DefaultAttribute(String name,String value) {
48          super(name, value);
49      }
50      
51      /*** Creates the <code>Attribute</code> with the specified local name,
52        * value and <code>Namespace</code>.
53        *
54        * @param name is the name of the attribute
55        * @param value is the value of the attribute
56        * @param namespace is the namespace of the attribute
57        */
58      public DefaultAttribute(String name,String value,Namespace namespace) {
59          super(name, value, namespace);
60      }
61      
62      /*** Creates the <code>Attribute</code> with the specified local name,
63        * value and <code>Namespace</code>.
64        *
65        * @param parent is the parent element
66        * @param name is the name of the attribute
67        * @param value is the value of the attribute
68        * @param namespace is the namespace of the attribute
69        */
70      public DefaultAttribute(Element parent,String name,String value,Namespace namespace) {
71          super(name, value, namespace);
72          this.parent = parent;
73      }
74  
75      public void setValue(String value) {
76      this.value = value;
77      }
78      
79      public Element getParent() {
80          return parent;
81      }
82  
83      public void setParent(Element parent) {
84          this.parent = parent;
85      }
86      
87      public boolean supportsParent() {
88          return true;
89      }
90      
91      public boolean isReadOnly() {
92          return false;
93      }
94  
95  }
96  
97  
98  
99  
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://www.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-2004 (C) MetaStuff, Ltd. All Rights Reserved.
141  *
142  * $Id: DefaultAttribute.java,v 1.11 2004/06/25 08:03:41 maartenc Exp $
143  */