KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dom4j > tree > DefaultAttribute


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.tree;
9
10 import org.dom4j.Element;
11 import org.dom4j.Namespace;
12 import org.dom4j.QName;
13
14 /**
15  * <p>
16  * <code>DefaultAttribute</code> implements a doubly linked node which
17  * supports the parent relationship and is mutable.
18  * </p>
19  *
20  * @author <a HREF="mailto:jstrachan@apache.org">James Strachan </a>
21  * @version $Revision: 1.13 $
22  */

23 public class DefaultAttribute extends FlyweightAttribute {
24     /** The parent of this node */
25     private Element parent;
26
27     public DefaultAttribute(QName qname) {
28         super(qname);
29     }
30
31     public DefaultAttribute(QName qname, String JavaDoc value) {
32         super(qname, value);
33     }
34
35     public DefaultAttribute(Element parent, QName qname, String JavaDoc value) {
36         super(qname, value);
37         this.parent = parent;
38     }
39
40     /**
41      * Creates the <code>Attribute</code> with the specified local name and
42      * value.
43      *
44      * @param name
45      * is the name of the attribute
46      * @param value
47      * is the value of the attribute
48      */

49     public DefaultAttribute(String JavaDoc name, String JavaDoc value) {
50         super(name, value);
51     }
52
53     /**
54      * Creates the <code>Attribute</code> with the specified local name, value
55      * and <code>Namespace</code>.
56      *
57      * @param name
58      * is the name of the attribute
59      * @param value
60      * is the value of the attribute
61      * @param namespace
62      * is the namespace of the attribute
63      */

64     public DefaultAttribute(String JavaDoc name, String JavaDoc value, Namespace namespace) {
65         super(name, value, namespace);
66     }
67
68     /**
69      * Creates the <code>Attribute</code> with the specified local name, value
70      * and <code>Namespace</code>.
71      *
72      * @param parent
73      * is the parent element
74      * @param name
75      * is the name of the attribute
76      * @param value
77      * is the value of the attribute
78      * @param namespace
79      * is the namespace of the attribute
80      */

81     public DefaultAttribute(Element parent, String JavaDoc name, String JavaDoc value,
82             Namespace namespace) {
83         super(name, value, namespace);
84         this.parent = parent;
85     }
86
87     public void setValue(String JavaDoc value) {
88         this.value = value;
89     }
90
91     public Element getParent() {
92         return parent;
93     }
94
95     public void setParent(Element parent) {
96         this.parent = parent;
97     }
98
99     public boolean supportsParent() {
100         return true;
101     }
102
103     public boolean isReadOnly() {
104         return false;
105     }
106 }
107
108 /*
109  * Redistribution and use of this software and associated documentation
110  * ("Software"), with or without modification, are permitted provided that the
111  * following conditions are met:
112  *
113  * 1. Redistributions of source code must retain copyright statements and
114  * notices. Redistributions must also contain a copy of this document.
115  *
116  * 2. Redistributions in binary form must reproduce the above copyright notice,
117  * this list of conditions and the following disclaimer in the documentation
118  * and/or other materials provided with the distribution.
119  *
120  * 3. The name "DOM4J" must not be used to endorse or promote products derived
121  * from this Software without prior written permission of MetaStuff, Ltd. For
122  * written permission, please contact dom4j-info@metastuff.com.
123  *
124  * 4. Products derived from this Software may not be called "DOM4J" nor may
125  * "DOM4J" appear in their names without prior written permission of MetaStuff,
126  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
127  *
128  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
129  *
130  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
131  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
132  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
133  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
134  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
135  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
136  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
137  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
138  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
139  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
140  * POSSIBILITY OF SUCH DAMAGE.
141  *
142  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
143  */

144
Popular Tags