NormalizerクラスのgetClass(char c)
メソッドがJava 6以降ではないようです。JavaのNormalizer.getClass(c)メソッドの置き換え6
このメソッドは、従来のコードに存在し、以下のように使用されています。 Java 6に移行する必要があります。どのように置き換えることができますか? java.text
から
import sun.text.Normalizer;
/**
* Returns an array of strings that have all the possible
* permutations of the characters in the input string.
* This is used to get a list of all possible orderings
* of a set of combining marks. Note that some of the permutations
* are invalid because of combining class collisions, and these
* possibilities must be removed because they are not canonically
* equivalent.
*/
private String[] producePermutations(String input) {
if (input.length() == 1)
return new String[] {input};
if (input.length() == 2) {
if (getClass(input.charAt(1)) ==
getClass(input.charAt(0))) {
return new String[] {input};
}
String[] result = new String[2];
result[0] = input;
StringBuffer sb = new StringBuffer(2);
sb.append(input.charAt(1));
sb.append(input.charAt(0));
result[1] = sb.toString();
return result;
}
int length = 1;
for(int x=1; x<input.length(); x++)
length = length * (x+1);
String[] temp = new String[length];
int combClass[] = new int[input.length()];
for(int x=0; x<input.length(); x++)
combClass[x] = getClass(input.charAt(x));
// For each char, take it out and add the permutations
// of the remaining chars
int index = 0;
loop: for(int x=0; x<input.length(); x++) {
boolean skip = false;
for(int y=x-1; y>=0; y--) {
if (combClass[y] == combClass[x]) {
continue loop;
}
}
StringBuffer sb = new StringBuffer(input);
String otherChars = sb.delete(x, x+1).toString();
String[] subResult = producePermutations(otherChars);
String prefix = input.substring(x, x+1);
for(int y=0; y<subResult.length; y++)
temp[index++] = prefix + subResult[y];
}
String[] result = new String[index];
for (int x=0; x<index; x++)
result[x] = temp[x];
return result;
}
private int getClass(char c) {
return Normalizer.getClass(c);
}
あなたはsun.text.Normailerを書きましたが、javadocをjava.text.Normalizerからリンクしました。これは間違いですか、それとも偶然あなたの質問に答えましたか? –
申し訳ありませんが、参照を削除しました。 – dazzle
'sun'パッケージからのクラスは時間の経過とともに' java'にマージされます。 'CharSequence'は別の例です。 –