コード例 #1
0
  public String[] splitWords(final String s) {
    if (Kits.STR.isEmpty(s)) {
      return Kits.STR.emptyArray();
    }
    final List<String> list = new ArrayList<>();
    final int len = s.length();
    int lastIndex = 0;
    for (int i = 1; i < len; ++i) {
      final char c = s.charAt(i);
      if (isWordEdge(c)) {
        list.add(s.substring(lastIndex, i));

        if (hasSeperator()) {
          lastIndex = i + 1;
        } else {
          lastIndex = i;
        }
      }
    }
    list.add(s.substring(lastIndex));
    return list.toArray(new String[list.size()]);
  }
コード例 #2
0
  public String convertTo(final LanguageLabelConverter targetFormat, final String source) {
    if (Kits.STR.isEmpty(source)) {
      return source;
    }

    final StringBuilder sb = new StringBuilder();

    targetFormat.handleFirstChar(sb, source.charAt(0));

    final int len = source.length();
    for (int i = 1; i < len; ++i) {
      final char c = source.charAt(i);
      if (isWordEdge(c)) {
        targetFormat.handleNextWordFirstChar(sb, c);
      } else {
        sb.append(c);
      }
    }
    return sb.toString();
  }