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