00001
00057 package com.arcle.rmt.j2se.util;
00058
00064 public final class StringUtilities {
00065 private StringUtilities() {
00066 throw new Error("StringUtilities is just a container for static methods");
00067 }
00068
00097 public static String stripChars(String str, int startIndex, int endIndex,
00098 char[] chars, boolean exclude) {
00099
00100 StringBuffer stripped = new StringBuffer(endIndex - startIndex + 1);
00101 for (int i=startIndex; i<=endIndex; i++) {
00102 boolean found = false;
00103 char current = str.charAt(i);
00104 for (int j=0; j<chars.length; j++) {
00105 if (current == chars[j]) {
00106 found = true;
00107 break;
00108 }
00109 }
00110
00111
00112 boolean shouldAppend = !(found == exclude);
00113 if (shouldAppend) {
00114 stripped.append(current);
00115 }
00116 }
00117 return stripped.toString();
00118 }
00119
00125 public static String stripAllExceptConsonantsOrFirstChar(String str) {
00126 return str.charAt(0) + stripChars(str, 1, str.length() - 1,
00127 CONSONANTS, false);
00128 }
00129
00130
00135 public static final char[] VOWELS = {
00136 'a', 'i', 'u', 'e', 'o',
00137 'A', 'I', 'U', 'E', 'O'
00138 };
00139
00144 public static final char[] CONSONANTS = {
00145 'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v',
00146 'w','x','y','z',
00147 'B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V',
00148 'W','X','Y','Z'
00149 };
00150 }