Exemple #1
0
  @VisibleForTesting
  static List<String> parseArgs(String commandLine) {
    List<String> terms = Lists.newArrayList();
    boolean dquoted = false;
    boolean squoted = false;
    char lastChar = 0;
    StringBuilder currentTerm = new StringBuilder();
    for (int i = 0; i != commandLine.length(); ++i) {
      char c = commandLine.charAt(i);
      if (!dquoted && !squoted && Character.isWhitespace(c)) {
        if (!Character.isWhitespace(lastChar)) {
          terms.add(currentTerm.toString());
          currentTerm.setLength(0);
        }
      } else if (!squoted && c == '"') {
        dquoted = !dquoted;

      } else if (!dquoted && c == '\'') {
        squoted = !squoted;

      } else {
        currentTerm.append(c);
      }
      lastChar = c;
    }
    if (currentTerm.length() > 0) {
      terms.add(currentTerm.toString());
    }
    return terms;
  }
Exemple #2
0
 @Internal("Sys.getlocale")
 public static String getLocale(int categoryIndex) {
   if (categoryIndex == LC_ALL) {
     StringBuilder info = new StringBuilder();
     boolean needsSemi = false;
     for (LocaleCategory category : LocaleCategory.values()) {
       if (needsSemi) {
         info.append(';');
       } else {
         needsSemi = true;
       }
       info.append(category.name()).append('=').append(category.value());
     }
     return info.toString();
   } else {
     return LocaleCategory.values()[categoryIndex - 2].value();
   }
 }