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: FlyweightAttribute.java,v 1.5 2004/06/25 08:03:41 maartenc Exp $ 8 */ 9 10 package org.dom4j.tree; 11 12 import org.dom4j.Namespace; 13 import org.dom4j.QName; 14 15 /*** <p><code>FlyweightAttribute</code> is a Flyweight pattern implementation 16 * of a singly linked, read-only XML Attribute.</p> 17 * 18 * <p>This node could be shared across documents and elements though 19 * it does not support the parent relationship.</p> 20 * 21 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 22 * @version $Revision: 1.5 $ 23 */ 24 public class FlyweightAttribute extends AbstractAttribute { 25 26 /*** The <code>QName</code> for this element */ 27 private QName qname; 28 29 /*** The value of the <code>Attribute</code> */ 30 protected String value; 31 32 33 public FlyweightAttribute(QName qname) { 34 this.qname = qname; 35 } 36 37 public FlyweightAttribute(QName qname,String value) { 38 this.qname = qname; 39 this.value = value; 40 } 41 42 /*** Creates the <code>Attribute</code> with the specified local name 43 * and value. 44 * 45 * @param name is the name of the attribute 46 * @param value is the value of the attribute 47 */ 48 public FlyweightAttribute(String name,String value) { 49 this.qname = getDocumentFactory().createQName(name); 50 this.value = value; 51 } 52 53 /*** Creates the <code>Attribute</code> with the specified local name, 54 * value and <code>Namespace</code>. 55 * 56 * @param name is the name of the attribute 57 * @param value is the value of the attribute 58 * @param namespace is the namespace of the attribute 59 */ 60 public FlyweightAttribute(String name,String value,Namespace namespace) { 61 this.qname = getDocumentFactory().createQName(name, namespace); 62 this.value = value; 63 } 64 65 public String getValue() { 66 return value; 67 } 68 69 public QName getQName() { 70 return qname; 71 } 72 } 73 74 75 76 77 /* 78 * Redistribution and use of this software and associated documentation 79 * ("Software"), with or without modification, are permitted provided 80 * that the following conditions are met: 81 * 82 * 1. Redistributions of source code must retain copyright 83 * statements and notices. Redistributions must also contain a 84 * copy of this document. 85 * 86 * 2. Redistributions in binary form must reproduce the 87 * above copyright notice, this list of conditions and the 88 * following disclaimer in the documentation and/or other 89 * materials provided with the distribution. 90 * 91 * 3. The name "DOM4J" must not be used to endorse or promote 92 * products derived from this Software without prior written 93 * permission of MetaStuff, Ltd. For written permission, 94 * please contact dom4j-info@metastuff.com. 95 * 96 * 4. Products derived from this Software may not be called "DOM4J" 97 * nor may "DOM4J" appear in their names without prior written 98 * permission of MetaStuff, Ltd. DOM4J is a registered 99 * trademark of MetaStuff, Ltd. 100 * 101 * 5. Due credit should be given to the DOM4J Project - 102 * http://www.dom4j.org 103 * 104 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 105 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 106 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 107 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 108 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 109 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 110 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 111 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 112 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 113 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 114 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 115 * OF THE POSSIBILITY OF SUCH DAMAGE. 116 * 117 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. 118 * 119 * $Id: FlyweightAttribute.java,v 1.5 2004/06/25 08:03:41 maartenc Exp $ 120 */