Ejemplo n.º 1
0
 protected static Vector /* of String */ stringToVector(String s, String delim) {
   Vector r = new Vector();
   int fromIndex = 0, len = s.length();
   ResultChar rc = new ResultChar();
   while (fromIndex < len) {
     rc.ch = 0;
     int i = indexOfAny(s, delim, fromIndex, rc);
     if (i == -1) {
       r.addElement(s.substring(fromIndex, len));
       break;
     }
     r.addElement(s.substring(fromIndex, i));
     /* Skip different delimiters. */
     i++;
     for (; i < len; i++) {
       if (s.charAt(i) == rc.ch || -1 == delim.indexOf(s.charAt(i))) break;
     }
     fromIndex = i;
   }
   return r;
 }
Ejemplo n.º 2
0
 protected static int indexOfAny(
     String s, String set, int fromIndex, /* RESULTS */ ResultChar rc) {
   int minIndex = 999999;
   char minChar = 0;
   boolean found = false;
   int len = set.length();
   for (int i = 0; i < len; i++) {
     char ch = set.charAt(i);
     int j = s.indexOf(set.charAt(i), fromIndex);
     if (j >= 0) {
       if ((!found) || j < minIndex) {
         found = true;
         minIndex = j;
         minChar = ch;
       }
     }
   }
   rc.ch = minChar;
   if (found) return minIndex;
   return -1;
 }