View Javadoc

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          String[] arr = cellStyleVal.split("//s*;//s*");
23          int len = arr.length;
24          String[] arrOut = new String[len];
25          for(int i=0; i<arr.length; i++){
26              String[] tarr = arr[i].split("//s*://s*");
27              if(tarr.length != 2){
28                  continue;
29              }
30              String key = tarr[0].trim();
31              String val = tarr[1].trim();
32              arrOut[i] = key + ":" + val + ";";
33          }
34          Arrays.sort(arrOut);
35          StringBuilder sb = new StringBuilder();
36          for(String str: arrOut){
37              sb.append(str);
38          }
39          return sb.toString();
40      }
41      
42      /*** Creates a new instance of POIStyleHashCreator */
43      private StyleHashCreator() {
44      }
45      
46  }
47