Coverage report

  %line %branch
org.apache.jetspeed.page.document.psml.NodeOrderCompartaor
0% 
0% 

 1  
 /*
 2  
 * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
 * contributor license agreements.  See the NOTICE file distributed with
 4  
 * this work for additional information regarding copyright ownership.
 5  
 * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
 * (the "License"); you may not use this file except in compliance with
 7  
 * the License.  You may obtain a copy of the License at
 8  
 *
 9  
 *     http://www.apache.org/licenses/LICENSE-2.0
 10  
 *
 11  
 * Unless required by applicable law or agreed to in writing, software
 12  
 * distributed under the License is distributed on an "AS IS" BASIS,
 13  
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
 * See the License for the specific language governing permissions and
 15  
 * limitations under the License.
 16  
 */
 17  
 /*
 18  
  * Created on Aug 31, 2004
 19  
  *
 20  
  * TODO To change the template for this generated file go to
 21  
  * Window - Preferences - Java - Code Generation - Code and Comments
 22  
  */
 23  
 package org.apache.jetspeed.page.document.psml;
 24  
 
 25  
 import java.util.Comparator;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * <p>
 30  
  * DocumentOrderCompartaor
 31  
  * </p>
 32  
  * <p>
 33  
  * 
 34  
  * </p>
 35  
  * 
 36  
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
 37  
  * @version $Id: NodeOrderCompartaor.java 516881 2007-03-11 10:34:21Z ate $
 38  
  *  
 39  
  */
 40  
 public class NodeOrderCompartaor implements Comparator
 41  
 {
 42  
     private List nodeIndex;
 43  0
     private String relativePath="";
 44  
 
 45  
     /**
 46  
      *  
 47  
      */
 48  
     public NodeOrderCompartaor( List nodeIndex, String relativePath )
 49  
     {
 50  0
         super();
 51  0
         this.nodeIndex = nodeIndex;        
 52  0
         this.relativePath = relativePath;
 53  0
     }
 54  
 
 55  
     /**
 56  
      * <p>
 57  
      * compare
 58  
      * </p>
 59  
      * 
 60  
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 61  
      * @param o1
 62  
      * @param o2
 63  
      * @return
 64  
      */
 65  
     public int compare( Object o1, Object o2 )
 66  
     {
 67  
         
 68  0
             String node1 = null;
 69  0
             String node2 = null;
 70  
        
 71  0
             if(relativePath.length() < o1.toString().length())
 72  
             {
 73  0
                 node1 =  o1.toString().substring(relativePath.length());
 74  
             }
 75  
             else
 76  
             {
 77  0
                 node1 =  o1.toString(); 
 78  
             }
 79  
             
 80  0
             if(relativePath.length() < o2.toString().length())
 81  
             {
 82  0
                 node2 =  o2.toString().substring(relativePath.length());
 83  
             }
 84  
             else
 85  
             {
 86  0
                 node2 =  o2.toString(); 
 87  
             }
 88  
 
 89  0
             String c1 = null;
 90  0
             String c2 = null;
 91  
 
 92  0
             if (nodeIndex != null)
 93  
             {
 94  0
                 int index1 = nodeIndex.indexOf(node1);
 95  0
                 int index2 = nodeIndex.indexOf(node2);
 96  
 
 97  0
                 if (index1 > -1)
 98  
                 {
 99  0
                     c1 = String.valueOf(index1);
 100  
                 }
 101  
                 else
 102  
                 {
 103  0
                     c1 = node1;
 104  
                 }
 105  
 
 106  0
                 if (index2 > -1)
 107  
                 {
 108  0
                     c2 = String.valueOf(index2);
 109  
                 }
 110  
                 else
 111  
                 {
 112  0
                     c2 = node2;
 113  
                 }
 114  0
             }
 115  
             else
 116  
             {
 117  0
                 c1 = node1;
 118  0
                 c2 = node2;
 119  
             }
 120  
 
 121  0
             return c1.compareTo(c2);
 122  
         
 123  
     }
 124  
 
 125  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.