|
JavaTM Platform Standard Ed. 6 |
|||||||||
앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요: 상자 | 필드 | 생성자 | 메소드 | 상세: 필드 | 생성자 | 메소드 |
java.lang.Objectjava.text.CollationKey
public abstract class CollationKey
CollationKey
는, 특정의 Collator
객체의 룰의 아래에서 있는 String
를 나타냅니다. 2 개의 CollationKey
를 비교하면(자), 그것들이 나타내는 String
의 상대 순서가 돌려주어집니다. CollationKey
를 사용해 String
를 비교하는 (분)편이 일반적으로 Collator.compare
보다 고속으로. 따라서, 복수의 String
를 몇번이나 비교하는 경우 (예를 들어,String
의 리스트를 소트 하는 경우)에는,CollationKey
를 사용하는 (분)편이 효율적입니다.
CollationKey
를 직접 작성할 수 없습니다. 그것들을 생성하려면 ,Collator.getCollationKey
를 호출할 필요가 있습니다. CollationKey
를 비교하는 경우, 그것들은 같은 Collator
객체로부터 생성하지 않으면 안됩니다.
String
의 CollationKey
를 생성하기 위해서는,String
전체를 조사해 그것을, 비트 단위로 비교할 수 있는 비트열로 변환할 필요가 있습니다. 이렇게 하면(자), 키가 생성된 후에, 비교가 고속으로 행해집니다. 키를 생성하는 코스트는,String
를 몇번이나 비교할 필요가 있는 경우에는, 고속의 비교에 의해 추가할 수가 있습니다. 한편, 비교의 결과는, 각각의 String
의 최초의 2 문자로 정해지는 일이 자주 있습니다. Collator.compare
에서는, 필요한 문자수만큼이 비교되므로, 단일의 비교에서는 이 (분)편이 고속으로.
다음의 예는,CollationKey
를 사용해,String
의 리스트를 소트 하는 경우를 나타낸 것입니다.
// Create an array of CollationKeys for the Strings to be sorted. Collator myCollator = Collator.getInstance(); CollationKey[] keys = new CollationKey[3]; keys[0] = myCollator.getCollationKey("Tom"); keys[1] = myCollator.getCollationKey("Dick"); keys[2] = myCollator.getCollationKey("Harry"); sort( keys );
//...
// Inside body of sort routine, compare keys this way if( keys[i]. compareTo( keys[j] ) > 0 ) // swap keys[i] and keys[j]
//...
// Finally, when we've returned from sort. System.out.println( keys[0]. getSourceString() ); System.out.println( keys[1]. getSourceString() ); System.out.println( keys[2]. getSourceString() );
Collator
,
RuleBasedCollator
생성자 의 개요 | |
---|---|
protected |
CollationKey (String source)
CollationKey 의 생성자 입니다. |
메소드의 개요 | |
---|---|
abstract int |
compareTo (CollationKey target)
이 CollationKey 를 타겟의 CollationKey 와 비교합니다. |
String |
getSourceString ()
이 CollationKey 가 나타내는 String 를 돌려줍니다. |
abstract byte[] |
toByteArray ()
CollationKey 를 비트열로 변환합니다. |
클래스 java.lang. Object 로부터 상속된 메소드 |
---|
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
생성자 의 상세 |
---|
protected CollationKey(String source)
source
- - 소스 캐릭터 라인
NullPointerException
- source
가 null 의 경우메소드의 상세 |
---|
public abstract int compareTo(CollationKey target)
Comparable <CollationKey >
내의 compareTo
target
- 타겟의 CollationKey
Collator.compare(java.lang.String, java.lang.String)
public String getSourceString()
public abstract byte[] toByteArray()
|
JavaTM Platform Standard Ed. 6 |
|||||||||
앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요: 상자 | 필드 | 생성자 | 메소드 | 상세: 필드 | 생성자 | 메소드 |
Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.