Clover coverage report - Code Coverage for tapestry-contrib release 4.0-rc-2
Coverage timestamp: Sat Dec 17 2005 09:47:13 PST
file stats: LOC: 111   Methods: 8
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimpleTreeDataModel.java 0% 0% 0% 0%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.contrib.tree.simple;
 16   
 17    import java.io.Serializable;
 18    import java.util.Iterator;
 19   
 20    import javax.swing.tree.TreePath;
 21   
 22    import org.apache.tapestry.contrib.tree.model.ITreeDataModel;
 23    import org.apache.tapestry.contrib.tree.model.ITreeNode;
 24   
 25    /**
 26    * @author ceco
 27    */
 28    public class SimpleTreeDataModel implements ITreeDataModel, Serializable
 29    {
 30    private static final long serialVersionUID = 9215832847660213349L;
 31   
 32    protected ITreeNode m_objRootNode;
 33    /**
 34    * Constructor for SimpleTreeDataModel.
 35    */
 36  0 public SimpleTreeDataModel(ITreeNode objRootNode) {
 37  0 super();
 38  0 m_objRootNode = objRootNode;
 39    }
 40   
 41    /**
 42    * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getRoot()
 43    */
 44  0 public Object getRoot() {
 45  0 return m_objRootNode;
 46    }
 47   
 48    /**
 49    * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getChildCount(Object)
 50    */
 51  0 public int getChildCount(Object objParent) {
 52  0 ITreeNode objParentNode = (ITreeNode)objParent;
 53   
 54  0 return objParentNode.getChildCount();
 55    }
 56   
 57    /**
 58    * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getChildren(Object)
 59    */
 60  0 public Iterator getChildren(Object objParent) {
 61  0 ITreeNode objParentNode = (ITreeNode)objParent;
 62  0 return objParentNode.getChildren().iterator();
 63    }
 64   
 65    /**
 66    * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getObject(Object)
 67    */
 68  0 public Object getObject(Object objUniqueKey) {
 69  0 if(objUniqueKey != null) {
 70  0 TreePath objPath = (TreePath)objUniqueKey;
 71  0 return objPath.getLastPathComponent();
 72    }
 73  0 return null;
 74    }
 75   
 76    /**
 77    * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getUniqueKey(Object, Object)
 78    */
 79  0 public Object getUniqueKey(Object objTarget, Object objParentUniqueKey) {
 80  0 TreePath objPath = (TreePath)objParentUniqueKey;
 81  0 Object objTargetUID = null;
 82  0 if(objPath != null){
 83  0 objTargetUID = objPath.pathByAddingChild(objTarget);
 84    }else{
 85  0 objTargetUID = new TreePath(objTarget);
 86    }
 87  0 return objTargetUID;
 88    }
 89   
 90    /**
 91    * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#isAncestorOf(Object, Object)
 92    */
 93  0 public boolean isAncestorOf(Object objTargetUniqueKey, Object objParentUniqueKey) {
 94  0 TreePath objParentPath = (TreePath)objParentUniqueKey;
 95  0 TreePath objTargetPath = (TreePath)objTargetUniqueKey;
 96  0 boolean bResult = objParentPath.isDescendant(objTargetPath);
 97  0 return bResult;
 98    }
 99   
 100    /**
 101    * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getParentUniqueKey
 102    */
 103  0 public Object getParentUniqueKey(Object objChildUniqueKey) {
 104  0 TreePath objChildPath = (TreePath)objChildUniqueKey;
 105  0 TreePath objParentPath = objChildPath.getParentPath();
 106  0 if(objParentPath == null)
 107  0 return null;
 108  0 return objParentPath.getLastPathComponent();
 109    }
 110   
 111    }