KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom4j > o3impl > FlyweightAttribute


1 /*
2  * Copyright 2001 (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: FlyweightAttribute.java,v 1.1 2003/11/02 18:10:03 per_nyfelt Exp $
8  */

9
10 package org.ozoneDB.xml.dom4j.o3impl;
11
12 import org.dom4j.Namespace;
13 import org.dom4j.NodeFactory;
14 import org.dom4j.QName;
15
16 /** <p><code>FlyweightAttribute</code> is a Flyweight pattern implementation
17  * of a singly linked, read-only XML Attribute.</p>
18  *
19  * <p>This node could be shared across documents and elements though
20  * it does not support the parent relationship.</p>
21  *
22  * @author <a HREF="mailto:jstrachan@apache.org">James Strachan</a>
23  * @version $Revision: 1.1 $
24  */

25 public class FlyweightAttribute extends AbstractAttribute {
26
27     /** The <code>QName</code> for this element */
28     private QName qname;
29
30     /** The value of the <code>Attribute</code> */
31     protected String JavaDoc value;
32
33
34     public FlyweightAttribute(QName qname) {
35         this.qname = qname;
36     }
37
38     public FlyweightAttribute(QName qname, String JavaDoc value) {
39         this.qname = qname;
40         this.value = value;
41     }
42
43     /** Creates the <code>Attribute</code> with the specified local name
44      * and value.
45      *
46      * @param nodeFactory is the Nodefactury used to create a QName from the name
47      * @param name is the name of the attribute
48      * @param value is the value of the attribute
49      */

50     public FlyweightAttribute(NodeFactory nodeFactory, String JavaDoc name, String JavaDoc value) {
51         setNodeFactory(nodeFactory);
52         this.qname = getNodeFactory().createQName(name);
53         this.value = value;
54     }
55
56     /** Creates the <code>Attribute</code> with the specified local name,
57      * value and <code>AbstractNamespace</code>.
58      *
59      * @param nodeFactory is the Nodefactury used to create a QName from the name
60      * @param name is the name of the attribute
61      * @param value is the value of the attribute
62      * @param namespace is the namespace of the attribute
63      */

64     public FlyweightAttribute(NodeFactory nodeFactory, String JavaDoc name, String JavaDoc value, Namespace namespace) {
65         setNodeFactory(nodeFactory);
66         this.qname = getNodeFactory().createQName(name, namespace);
67         this.value = value;
68     }
69
70     public String JavaDoc getValue() {
71         return value;
72     }
73
74     public QName getQName() {
75         return qname;
76     }
77 }
78
79
80 /*
81  * Redistribution and use of this software and associated documentation
82  * ("Software"), with or without modification, are permitted provided
83  * that the following conditions are met:
84  *
85  * 1. Redistributions of source code must retain copyright
86  * statements and notices. Redistributions must also contain a
87  * copy of this document.
88  *
89  * 2. Redistributions in binary form must reproduce the
90  * above copyright notice, this list of conditions and the
91  * following disclaimer in the documentation and/or other
92  * materials provided with the distribution.
93  *
94  * 3. The name "DOM4J" must not be used to endorse or promote
95  * products derived from this Software without prior written
96  * permission of MetaStuff, Ltd. For written permission,
97  * please contact dom4j-info@metastuff.com.
98  *
99  * 4. Products derived from this Software may not be called "DOM4J"
100  * nor may "DOM4J" appear in their names without prior written
101  * permission of MetaStuff, Ltd. DOM4J is a registered
102  * trademark of MetaStuff, Ltd.
103  *
104  * 5. Due credit should be given to the DOM4J Project
105  * (http://dom4j.org/).
106  *
107  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
108  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
109  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
110  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
111  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
112  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
113  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
114  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
115  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
116  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
117  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
118  * OF THE POSSIBILITY OF SUCH DAMAGE.
119  *
120  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
121  *
122  * $Id: FlyweightAttribute.java,v 1.1 2003/11/02 18:10:03 per_nyfelt Exp $
123  */

124
Popular Tags