Coverage Report - org.wiztools.xml2spreadsheet.util.StyleHashCreator
 
Classes in this File Line Coverage Branch Coverage Complexity
StyleHashCreator
82% 
100% 
0
 
 1  
 /*
 2  
  * POIStyleHashCreator.java
 3  
  *
 4  
  * Created on November 14, 2006, 3:09 PM
 5  
  *
 6  
  * To change this template, choose Tools | Template Manager
 7  
  * and open the template in the editor.
 8  
  */
 9  
 
 10  
 package org.wiztools.xml2spreadsheet.util;
 11  
 
 12  
 import java.util.Arrays;
 13  
 
 14  
 /**
 15  
  * This class creates a Hash of the style value provided for a cell.
 16  
  * The hash is nothing but the key/value pairs organized in a sorted format.
 17  
  * @author subhash
 18  
  */
 19  
 public class StyleHashCreator {
 20  
     
 21  
     public static String getHash(final String cellStyleVal){
 22  106846
         String[] arr = cellStyleVal.split("\\s*;\\s*");
 23  106846
         int len = arr.length;
 24  106846
         String[] arrOut = new String[len];
 25  549622
         for(int i=0; i<arr.length; i++){
 26  442776
             String[] tarr = arr[i].split("\\s*:\\s*");
 27  442776
             if(tarr.length != 2){
 28  0
                 continue;
 29  
             }
 30  442776
             String key = tarr[0].trim();
 31  442776
             String val = tarr[1].trim();
 32  442776
             arrOut[i] = key + ":" + val + ";";
 33  
         }
 34  106846
         Arrays.sort(arrOut);
 35  106846
         StringBuilder sb = new StringBuilder();
 36  549622
         for(String str: arrOut){
 37  442776
             sb.append(str);
 38  
         }
 39  106846
         return sb.toString();
 40  
     }
 41  
     
 42  
     /** Creates a new instance of POIStyleHashCreator */
 43  0
     private StyleHashCreator() {
 44  0
     }
 45  
     
 46  
 }
 47