|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Object | +--java.text.CollationElementIterator
CollationElementIterator
クラスは、各国語文字列の各文字を処理するときの反復子として使用します。反復子は、位置付けされた文字の順序の優先順位を返すのに使用されます。順序の優先順位 (キーと呼ぶ) は、指定された照合オブジェクトにおいて、ある文字がどのように照合されるかを定義するものです。
スペイン語の例を示します。
さらに、ドイツ語の例を示します。"ca" -> 最初のキーは ('c')、2 番目のキーは ('a') です。 "cha" -> 最初のキーは ('ch')、2 番目のキーは ('a') です。
文字のキーは、第 1 順序 (short)、第 2 順序 (byte)、第 3 順序 (byte) からなる整数です。Java では、その基本データ型のサイズと符号の有無が厳密に定義されます。したがって、static 関数"ä" -> 最初のキーは ('a')、2 番目のキーは ('e')、 3 番目のキーは ('b') です。
primaryOrder
、secondaryOrder
、tertiaryOrder
は、キー値の正確性を確保するために、それぞれ int
、short
、short
を返します。
反復子の使用例
// get the first key of the string String str = "This is a test"; CollationElementIterator c = new CollationElementIterator(str, 0, str.length(), Collator.getInstance()); int primaryOrder = CollationElementIterator.primaryOrder(c->next());
CollationElementIterator.next
は、次の文字の照合順序を返します。照合順序は、第 1 順序、第 2 順序、第 3 順序からなります。照合順序のデータ型は int です。照合順序の最初の 16 ビットがその第 1 順序、次の 8 ビットが第 2 順序、最後の 8 ビットが第 3 順序です。
Collator
,
RuleBasedCollator
フィールドの概要 | |
static int |
NULLORDER
カーソルが文字列の終わりに達したことを示す null 順序です。 |
メソッドの概要 | |
int |
getMaxExpansion(int order)
指定された比較順序で終わるすべての展開シーケンスの最大長を返します。 |
int |
getOffset()
ソーステキストの現在の文字のオフセットを取得します。 |
int |
next()
文字列内の次の文字の優先順位を取得します。 |
int |
previous()
文字列内の前の文字の優先順位を取得します。 |
static int |
primaryOrder(int order)
照合順序の第 1 順序を取得します。 |
void |
reset()
カーソルを文字列の先頭にリセットします。 |
static short |
secondaryOrder(int order)
照合順序の第 2 順序を取得します。 |
void |
setOffset(int newOffset)
ソーステキスト内の位置を設定します。 |
void |
setText(CharacterIterator source)
繰り返し処理の対象となる新しい文字列を設定します。 |
void |
setText(String source)
繰り返し処理の対象となる新しい文字列を設定します。 |
static short |
tertiaryOrder(int order)
照合順序の第 3 順序を取得します。 |
クラス java.lang.Object から継承したメソッド |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
フィールドの詳細 |
public static final int NULLORDER
メソッドの詳細 |
public void reset()
public int next()
public int previous()
public static final int primaryOrder(int order)
order
- 照合順序public static final short secondaryOrder(int order)
order
- 照合順序public static final short tertiaryOrder(int order)
order
- 照合順序public void setOffset(int newOffset)
newOffset
- テキストの先頭を基準にした新しいオフセットpublic int getOffset()
public int getMaxExpansion(int order)
order
- previous または next が返す照合順序public void setText(String source)
source
- 新しいソーステキストpublic void setText(CharacterIterator source)
source
- 新しいソーステキスト
|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |