コード例 #1
0
ファイル: Utils.java プロジェクト: Bama4255/IRC-Extended
 public static String[] splitwords(String text) {
   ArrayList<String> words = new ArrayList<String>();
   StringBuilder buf = new StringBuilder();
   String st = "ws";
   int i = 0;
   while (i < text.length()) {
     char c = text.charAt(i);
     if (st == "ws") {
       if (!Character.isWhitespace(c)) st = "word";
       else i++;
     } else if (st == "word") {
       if (c == '"') {
         st = "quote";
         i++;
       } else if (c == '\\') {
         st = "squote";
         i++;
       } else if (Character.isWhitespace(c)) {
         words.add(buf.toString());
         buf = new StringBuilder();
         st = "ws";
       } else {
         buf.append(c);
         i++;
       }
     } else if (st == "quote") {
       if (c == '"') {
         st = "word";
         i++;
       } else if (c == '\\') {
         st = "sqquote";
         i++;
       } else {
         buf.append(c);
         i++;
       }
     } else if (st == "squote") {
       buf.append(c);
       i++;
       st = "word";
     } else if (st == "sqquote") {
       buf.append(c);
       i++;
       st = "quote";
     }
   }
   if (st == "word") words.add(buf.toString());
   if ((st != "ws") && (st != "word")) return (null);
   return (words.toArray(new String[0]));
 }
コード例 #2
0
ファイル: Utils.java プロジェクト: Bama4255/IRC-Extended
 public static String[] splitlines(String text) {
   ArrayList<String> ret = new ArrayList<String>();
   int p = 0;
   while (true) {
     int p2 = text.indexOf('\n', p);
     if (p2 < 0) {
       ret.add(text.substring(p));
       break;
     }
     ret.add(text.substring(p, p2));
     p = p2 + 1;
   }
   return (ret.toArray(new String[0]));
 }
コード例 #3
0
  // --------------------------------------------------------------
  // --------------------------------------------------------------
  public static Version[] getAvailablePrefVersions(Preferences prefs) throws BackingStoreException {
    String[] sver = prefs.childrenNames();
    ArrayList l = new ArrayList(sver.length);
    for (int i = 0; i < sver.length; ++i) {
      try {
        l.add(new Version(sver[i]));
      } catch (Exception e) {
      }
    }

    int n = 0;
    Version[] ret = new Version[l.size()];
    for (Iterator ii = l.iterator(); ii.hasNext(); ) {
      Version v = (Version) ii.next();
      ret[n++] = v;
    }
    return ret;
  }