Clover coverage report - Code Coverage for tapestry-contrib release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:12:41 EDT
file stats: LOC: 110   Methods: 8
NCLOC: 54   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 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   
     protected ITreeNode m_objRootNode;
 31   
     /**
 32   
      * Constructor for SimpleTreeDataModel.
 33   
      */
 34  0
     public SimpleTreeDataModel(ITreeNode objRootNode) {
 35  0
         super();
 36  0
         m_objRootNode = objRootNode;
 37   
     }
 38   
 
 39   
     /**
 40   
      * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getRoot()
 41   
      */
 42  0
     public Object getRoot() {
 43  0
         return m_objRootNode;
 44   
     }
 45   
 
 46   
     /**
 47   
      * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getChildCount(Object)
 48   
      */
 49  0
     public int getChildCount(Object objParent) {
 50  0
         ITreeNode objParentNode = (ITreeNode)objParent;
 51   
         
 52  0
         return objParentNode.getChildCount();
 53   
     }
 54   
 
 55   
     /**
 56   
      * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getChildren(Object)
 57   
      */
 58  0
     public Iterator getChildren(Object objParent) {
 59  0
         ITreeNode objParentNode = (ITreeNode)objParent;
 60  0
         return objParentNode.getChildren().iterator();
 61   
     }
 62   
 
 63   
     /**
 64   
      * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getObject(Object)
 65   
      */
 66  0
     public Object getObject(Object objUniqueKey) {
 67  0
         if(objUniqueKey != null) {
 68  0
             TreePath objPath = (TreePath)objUniqueKey;
 69  0
             return objPath.getLastPathComponent();
 70   
         }
 71  0
         return null;
 72   
     }
 73   
 
 74   
     /**
 75   
      * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getUniqueKey(Object, Object)
 76   
      */
 77  0
     public Object getUniqueKey(Object objTarget, Object objParentUniqueKey) {
 78  0
         TreePath objPath = (TreePath)objParentUniqueKey;
 79  0
         Object objTargetUID = null;
 80  0
         if(objPath != null){
 81  0
             objTargetUID = objPath.pathByAddingChild(objTarget);
 82   
         }else{
 83  0
             objTargetUID = new TreePath(objTarget);
 84   
         }
 85  0
         return objTargetUID;
 86   
     }
 87   
 
 88   
     /**
 89   
      * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#isAncestorOf(Object, Object)
 90   
      */
 91  0
     public boolean isAncestorOf(Object objTargetUniqueKey, Object objParentUniqueKey) {
 92  0
         TreePath objParentPath = (TreePath)objParentUniqueKey;
 93  0
         TreePath objTargetPath = (TreePath)objTargetUniqueKey;
 94  0
         boolean bResult = objParentPath.isDescendant(objTargetPath);
 95  0
         return bResult;
 96   
     }
 97   
 
 98   
     /**
 99   
      * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#getParentUniqueKey
 100   
      */
 101  0
     public Object getParentUniqueKey(Object objChildUniqueKey) {
 102  0
         TreePath objChildPath = (TreePath)objChildUniqueKey;
 103  0
         TreePath objParentPath = objChildPath.getParentPath();
 104  0
         if(objParentPath == null)
 105  0
             return null;
 106  0
         return objParentPath.getLastPathComponent();
 107   
     }
 108   
 
 109   
 }
 110