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: FlyweightText.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.Text;
015import org.dom4j.Visitor;
016
017/** <p><code>FlyweightText</code> is a Flyweight pattern implementation
018  * of a singly linked, read-only XML Text.</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 FlyweightText extends AbstractText implements Text {
027
028    /** Text of the <code>Text</code> node */
029    protected String text;
030
031    /** @param text is the Text text
032      */
033    public FlyweightText(String text) {
034        this.text = text;
035    }
036
037    public String getText() {
038        return text;
039    }
040    
041    protected Node createXPathResult(Element parent) {
042        return new DefaultText( parent, getText() );
043    }
044}
045
046
047
048
049/*
050 * Redistribution and use of this software and associated documentation
051 * ("Software"), with or without modification, are permitted provided
052 * that the following conditions are met:
053 *
054 * 1. Redistributions of source code must retain copyright
055 *    statements and notices.  Redistributions must also contain a
056 *    copy of this document.
057 *
058 * 2. Redistributions in binary form must reproduce the
059 *    above copyright notice, this list of conditions and the
060 *    following disclaimer in the documentation and/or other
061 *    materials provided with the distribution.
062 *
063 * 3. The name "DOM4J" must not be used to endorse or promote
064 *    products derived from this Software without prior written
065 *    permission of MetaStuff, Ltd.  For written permission,
066 *    please contact dom4j-info@metastuff.com.
067 *
068 * 4. Products derived from this Software may not be called "DOM4J"
069 *    nor may "DOM4J" appear in their names without prior written
070 *    permission of MetaStuff, Ltd. DOM4J is a registered
071 *    trademark of MetaStuff, Ltd.
072 *
073 * 5. Due credit should be given to the DOM4J Project
074 *    (http://dom4j.org/).
075 *
076 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
077 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
078 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
079 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
080 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
081 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
082 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
083 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
084 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
085 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
086 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
087 * OF THE POSSIBILITY OF SUCH DAMAGE.
088 *
089 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
090 *
091 * $Id: FlyweightText.java,v 1.1 2001/06/20 18:59:23 jstrachan Exp $
092 */