Coverage Report - org.apache.tapestry.asset.AssetComparator
 
Classes in this File Line Coverage Branch Coverage Complexity
AssetComparator
0%
0/10
0%
0/16
10
 
 1  
 // Copyright Apr 15, 2006 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  
 package org.apache.tapestry.asset;
 15  
 
 16  
 import java.util.Comparator;
 17  
 
 18  
 
 19  
 /**
 20  
  * Used to guarantee that whenever present, the PATH key entry 
 21  
  * of an asset service link is always appended last in that path
 22  
  * string. This is required for certain relative url operations. (ie dojo baseRelativePath)
 23  
  * 
 24  
  * @author jkuhnert
 25  
  */
 26  0
 public class AssetComparator implements Comparator
 27  
 {
 28  
 
 29  
     /** 
 30  
      * {@inheritDoc}
 31  
      */
 32  
     public int compare(Object o1, Object o2)
 33  
     {
 34  0
         if (!String.class.isInstance(o1) || !String.class.isInstance(o2))
 35  0
             return 1;
 36  
         
 37  0
         String key1 = (String)o1;
 38  0
         String key2 = (String)o2;
 39  
         
 40  0
         if (key1.toUpperCase().equals("PATH") && !key2.toUpperCase().equals("PATH"))
 41  0
             return 1;
 42  0
         else if (key2.toUpperCase().equals("PATH") && !key1.toUpperCase().equals("PATH"))
 43  0
             return -1;
 44  0
         else return key1.compareToIgnoreCase(key2);
 45  
     }
 46  
 
 47  
 }