Clover coverage report - dom4j - 1.5
Coverage timestamp: vr sep 3 2004 20:47:03 GMT+01:00
file stats: LOC: 151   Methods: 15
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LeafTreeNode.java 0% 0% 0% 0%
coverage
 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: LeafTreeNode.java,v 1.5 2004/06/25 08:03:40 maartenc Exp $
 8    */
 9   
 10    package org.dom4j.swing;
 11   
 12    import java.util.Enumeration;
 13   
 14    import javax.swing.tree.TreeNode;
 15   
 16    import org.dom4j.Node;
 17   
 18    /** <p><code>LeafTreeNode</code> implements the Swing TreeNode interface
 19    * to bind a leaf XML nodes to a Swing TreeModel.</p>
 20    *
 21    * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> (james.strachan@metastuff.com)
 22    * @author Jakob Jenkov
 23    * @version $Revision: 1.5 $
 24    */
 25    public class LeafTreeNode implements TreeNode {
 26   
 27    protected static final Enumeration EMPTY_ENUMERATION = new Enumeration() {
 28  0 public boolean hasMoreElements() {
 29  0 return false;
 30    }
 31  0 public Object nextElement() {
 32  0 return null;
 33    }
 34    };
 35   
 36    /** The parent node of this TreeNode */
 37    private TreeNode parent;
 38   
 39    /** The dom4j Node which contains the */
 40    protected Node xmlNode;
 41   
 42   
 43  0 public LeafTreeNode() {
 44    }
 45   
 46  0 public LeafTreeNode(Node xmlNode) {
 47  0 this.xmlNode = xmlNode;
 48    }
 49   
 50  0 public LeafTreeNode(TreeNode parent, Node xmlNode) {
 51  0 this.parent = parent;
 52  0 this.xmlNode = xmlNode;
 53    }
 54   
 55   
 56    // TreeNode methods
 57    //-------------------------------------------------------------------------
 58  0 public Enumeration children() {
 59  0 return EMPTY_ENUMERATION;
 60    }
 61   
 62  0 public boolean getAllowsChildren() {
 63  0 return false;
 64    }
 65   
 66  0 public TreeNode getChildAt(int childIndex) {
 67  0 return null;
 68    }
 69   
 70  0 public int getChildCount() {
 71  0 return 0;
 72    }
 73   
 74  0 public int getIndex(TreeNode node) {
 75  0 return -1;
 76    }
 77   
 78  0 public TreeNode getParent() {
 79  0 return parent;
 80    }
 81   
 82  0 public boolean isLeaf() {
 83  0 return true;
 84    }
 85   
 86  0 public String toString() {
 87    // should maybe do things differently based on content?
 88  0 String text = xmlNode.getText();
 89  0 return (text != null) ? text.trim() : "";
 90    }
 91   
 92    // Properties
 93    //-------------------------------------------------------------------------
 94   
 95    /** Sets the parent of this node but doesn't change the parents children */
 96  0 public void setParent(LeafTreeNode parent) {
 97  0 this.parent = parent;
 98    }
 99   
 100  0 public Node getXmlNode() {
 101  0 return xmlNode;
 102    }
 103    }
 104   
 105   
 106   
 107   
 108    /*
 109    * Redistribution and use of this software and associated documentation
 110    * ("Software"), with or without modification, are permitted provided
 111    * that the following conditions are met:
 112    *
 113    * 1. Redistributions of source code must retain copyright
 114    * statements and notices. Redistributions must also contain a
 115    * copy of this document.
 116    *
 117    * 2. Redistributions in binary form must reproduce the
 118    * above copyright notice, this list of conditions and the
 119    * following disclaimer in the documentation and/or other
 120    * materials provided with the distribution.
 121    *
 122    * 3. The name "DOM4J" must not be used to endorse or promote
 123    * products derived from this Software without prior written
 124    * permission of MetaStuff, Ltd. For written permission,
 125    * please contact dom4j-info@metastuff.com.
 126    *
 127    * 4. Products derived from this Software may not be called "DOM4J"
 128    * nor may "DOM4J" appear in their names without prior written
 129    * permission of MetaStuff, Ltd. DOM4J is a registered
 130    * trademark of MetaStuff, Ltd.
 131    *
 132    * 5. Due credit should be given to the DOM4J Project -
 133    * http://www.dom4j.org
 134    *
 135    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
 136    * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 137    * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 138    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 139    * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 140    * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 141    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 142    * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 143    * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 144    * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 145    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 146    * OF THE POSSIBILITY OF SUCH DAMAGE.
 147    *
 148    * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
 149    *
 150    * $Id: LeafTreeNode.java,v 1.5 2004/06/25 08:03:40 maartenc Exp $
 151    */