public static Hashtable<String,String> sortClassesByRoot(String classes){
  Hashtable<String,Vector<String>> roots;
  Hashtable<String,String> result;
  Enumeration<String> enm;
  int i;
  StringTokenizer tok;
  String clsname;
  Vector<String> list;
  HierarchyPropertyParser hpp;
  String separator;
  String root;
  String tmpStr;
  if (classes == null) {
    return null;
  }
  roots=new Hashtable<String,Vector<String>>();
  hpp=new HierarchyPropertyParser();
  separator=hpp.getSeperator();
  tok=new StringTokenizer(classes,", ");
  while (tok.hasMoreElements()) {
    clsname=tok.nextToken();
    root=getRootFromClass(clsname,separator);
    if (root == null) {
      continue;
    }
    if (!roots.containsKey(root)) {
      list=new Vector<String>();
      roots.put(root,list);
    }
 else {
      list=roots.get(root);
    }
    list.add(clsname);
  }
  result=new Hashtable<String,String>();
  enm=roots.keys();
  while (enm.hasMoreElements()) {
    root=enm.nextElement();
    list=roots.get(root);
    tmpStr="";
    for (i=0; i < list.size(); i++) {
      if (i > 0) {
        tmpStr+=",";
      }
      tmpStr+=list.get(i);
    }
    result.put(root,tmpStr);
  }
  return result;
}

public static Hashtable < String , String > sortClassesByRoot ( String classes ) { Hashtable < String , Vector < String > > roots ; Hashtable < String , String > result ; Enumeration < String > enm ; int i ; StringTokenizer tok ; String clsname ; Vector < String > list ; HierarchyPropertyParser hpp ; String separator ; String root ; String tmpStr ; if ( classes == null ) { return null ; } roots = new Hashtable < String , Vector < String > > ( ) ; hpp = new HierarchyPropertyParser ( ) ; separator = hpp . getSeperator ( ) ; tok = new StringTokenizer ( classes , ", " ) ; while ( tok . hasMoreElements ( ) ) { clsname = tok . nextToken ( ) ; root = getRootFromClass ( clsname , separator ) ; if ( root == null ) { continue ; } if ( ! roots . containsKey ( root ) ) { list = new Vector < String > ( ) ; roots . put ( root , list ) ; } else { list = roots . get ( root ) ; } list . add ( clsname ) ; } result = new Hashtable < String , String > ( ) ; enm = roots . keys ( ) ; while ( enm . hasMoreElements ( ) ) { root = enm . nextElement ( ) ; list = roots . get ( root ) ; tmpStr = "" ; for ( i = 0 ; i < list . size ( ) ; i ++ ) { if ( i > 0 ) { tmpStr += "," ; } tmpStr += list . get ( i ) ; } result . put ( root , tmpStr ) ; } return result ; }
parses the given string of classes separated by " , " and returns the a hashtable with as many entries as there are different root elements in the class names ( the key is the root element ) . e . g . if there ' s only " weka . " as the prefix for all classes the a hashtable of size 1 is returned . if null is the input , then null is also returned .
