|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| FlyweightText.java | - | 66,7% | 66,7% | 66,7% |
|
||||||||||||||
| 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: FlyweightText.java,v 1.5 2004/06/25 08:03:41 maartenc Exp $ | |
| 8 | */ | |
| 9 | ||
| 10 | package org.dom4j.tree; | |
| 11 | ||
| 12 | import org.dom4j.Element; | |
| 13 | import org.dom4j.Node; | |
| 14 | import org.dom4j.Text; | |
| 15 | ||
| 16 | /** <p><code>FlyweightText</code> is a Flyweight pattern implementation | |
| 17 | * of a singly linked, read-only XML Text.</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.5 $ | |
| 24 | */ | |
| 25 | public class FlyweightText extends AbstractText implements Text { | |
| 26 | ||
| 27 | /** Text of the <code>Text</code> node */ | |
| 28 | protected String text; | |
| 29 | ||
| 30 | /** @param text is the Text text | |
| 31 | */ | |
| 32 | 212962 | public FlyweightText(String text) { |
| 33 | 212934 | this.text = text; |
| 34 | } | |
| 35 | ||
| 36 | 662704 | public String getText() { |
| 37 | 662704 | return text; |
| 38 | } | |
| 39 | ||
| 40 | 0 | protected Node createXPathResult(Element parent) { |
| 41 | 0 | return new DefaultText( parent, getText() ); |
| 42 | } | |
| 43 | } | |
| 44 | ||
| 45 | ||
| 46 | ||
| 47 | ||
| 48 | /* | |
| 49 | * Redistribution and use of this software and associated documentation | |
| 50 | * ("Software"), with or without modification, are permitted provided | |
| 51 | * that the following conditions are met: | |
| 52 | * | |
| 53 | * 1. Redistributions of source code must retain copyright | |
| 54 | * statements and notices. Redistributions must also contain a | |
| 55 | * copy of this document. | |
| 56 | * | |
| 57 | * 2. Redistributions in binary form must reproduce the | |
| 58 | * above copyright notice, this list of conditions and the | |
| 59 | * following disclaimer in the documentation and/or other | |
| 60 | * materials provided with the distribution. | |
| 61 | * | |
| 62 | * 3. The name "DOM4J" must not be used to endorse or promote | |
| 63 | * products derived from this Software without prior written | |
| 64 | * permission of MetaStuff, Ltd. For written permission, | |
| 65 | * please contact dom4j-info@metastuff.com. | |
| 66 | * | |
| 67 | * 4. Products derived from this Software may not be called "DOM4J" | |
| 68 | * nor may "DOM4J" appear in their names without prior written | |
| 69 | * permission of MetaStuff, Ltd. DOM4J is a registered | |
| 70 | * trademark of MetaStuff, Ltd. | |
| 71 | * | |
| 72 | * 5. Due credit should be given to the DOM4J Project - | |
| 73 | * http://www.dom4j.org | |
| 74 | * | |
| 75 | * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS | |
| 76 | * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT | |
| 77 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 78 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
| 79 | * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 80 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 81 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 82 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 83 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 84 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 85 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| 86 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 87 | * | |
| 88 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
| 89 | * | |
| 90 | * $Id: FlyweightText.java,v 1.5 2004/06/25 08:03:41 maartenc Exp $ | |
| 91 | */ |
|
||||||||||