|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
java.lang.Objectjava.text.Collator
public abstract class Collator
Collator
��ִ���������Ի����� String
�Ƚϡ�ʹ�ô����Ϊ��Ȼ�����ı������������������̡�
Collator
��һ��������ࡣ������ʵ�־�����������ԡ�Java ƽ̨Ŀǰ�ṩ�� RuleBasedCollator
���࣬�������ںܶ������ԡ������Դ����������࣬�Դ��������ר����Ҫ��
�������������Ի�������һ��������ʹ�þ�̬�������� getInstance
��Ϊ���������Ի�������ʵ��� Collator
���������Ҫ�����ض��������Ե�ϸ�ڻ�����Ҫ�IJ��ԣ�ֻ��鿴 Collator
�����༴�ɡ�
�����ʾ����ʾ�����ʹ�����Ĭ�����Ի����� Collator
�Ƚ������ַ�����
// Compare two strings in the default locale Collator myCollator = Collator.getInstance(); if( myCollator.compare("abc", "ABC") < 0 ) System.out.println("abc is less than ABC"); else System.out.println("abc is greater than or equal to ABC");
�������� Collator
�� strength ������ȷ���Ƚ�����Ϊ�����IJ��켶���ṩ������ strength��PRIMARY
��SECONDARY
��TERTIARY
�� IDENTICAL
��������������ȷ�� strength ��ֵ�����Ի�����ء������ڽݿ����У�"e" �� "f" ����Ϊ�� PRIMARY ���죬�� "e" �� "ě" ���� SECONDARY ���죬"e" �� "E" �� TERTIARY ���죬"e" �� "e" �� IDENTICAL�������ʾ����ʾ������������Ӣ����Դ�Сд��������
//Get the Collator for US English and set its strength to PRIMARY Collator usCollator = Collator.getInstance(Locale.US); usCollator.setStrength(Collator.PRIMARY); if( usCollator.compare("abc", "ABC") == 0 ) { System.out.println("Strings are equivalent"); }
������ñȽ� String
һ�Σ��� compare
�������ṩ������ܡ����ڶ� String
�б�����ʱ��ͨ����Ҫ��ÿ�� String
���ж�αȽϡ�����������£�CollationKey
���ṩ���õ����ܡ�CollationKey
�ཫһ�� String
ת����һϵ�п������� CollationKey
���а�λ�Ƚϵ�λ��CollationKey
���� Collator
���������� String
�������ġ�
ע�����ܱȽ��ɲ�ͬ Collator
������ CollationKey
���й�ʹ�� CollationKey
��ʾ��������� CollationKey
����������
RuleBasedCollator
,
CollationKey
,
CollationElementIterator
,
Locale
�ֶ�ժҪ | |
---|---|
static int |
CANONICAL_DECOMPOSITION
Decomposition ģʽֵ�� |
static int |
FULL_DECOMPOSITION
Decomposition ģʽֵ�� |
static int |
IDENTICAL
Collator �� strength ֵ�� |
static int |
NO_DECOMPOSITION
Decomposition ģʽֵ�� |
static int |
PRIMARY
Collator �� strength ֵ�� |
static int |
SECONDARY
Collator �� strength ֵ�� |
static int |
TERTIARY
Collator �� strength ֵ�� |
���췽��ժҪ | |
---|---|
protected |
Collator()
Ĭ�ϵĹ��췽���� |
����ժҪ | |
---|---|
Object |
clone()
��д Cloneable |
int |
compare(Object o1,
Object o2)
�Ƚϴ˷�������������˳�� |
abstract int |
compare(String source,
String target)
���ݴ� Collator �������������Ƚ�Դ�ַ�����Ŀ���ַ����� |
boolean |
equals(Object that)
�Ƚ����� Collator ������ԡ� |
boolean |
equals(String source,
String target)
���ݴ� Collator ����������Ƚ������ַ����Ƿ���ȵı�ݷ����� |
static Locale[] |
getAvailableLocales()
����һ��������֧�����Ի��������飬����� getInstance ������Ϊ��Щ���Ի��������ѱ��ػ���ʵ���� |
abstract CollationKey |
getCollationKey(String source)
���� String ת��Ϊһϵ�п��Ժ����� CollationKey ��λ���бȽϵ�λ�� |
int |
getDecomposition()
��ȡ�� Collator �� decomposition ģʽ�� |
static Collator |
getInstance()
��ȡ��ǰĬ�����Ի����� Collator�� |
static Collator |
getInstance(Locale desiredLocale)
��ȡ�������Ի����� Collator�� |
int |
getStrength()
���ش� Collator �� strength ���ԡ� |
abstract int |
hashCode()
���ɴ� Collator �Ĺ�ϣ�롣 |
void |
setDecomposition(int decompositionMode)
���ô� Collator �� decomposition ģʽ�� |
void |
setStrength(int newStrength)
���ô� Collator �� strength ���ԡ� |
���� java.lang.Object �̳еķ��� |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
�ֶ���ϸ��Ϣ |
---|
public static final int PRIMARY
setStrength(int)
,
getStrength()
,
�����ֶ�ֵpublic static final int SECONDARY
setStrength(int)
,
getStrength()
,
�����ֶ�ֵpublic static final int TERTIARY
setStrength(int)
,
getStrength()
,
�����ֶ�ֵpublic static final int IDENTICAL
public static final int NO_DECOMPOSITION
getDecomposition()
,
setDecomposition(int)
,
�����ֶ�ֵpublic static final int CANONICAL_DECOMPOSITION
CANONICAL_DECOMPOSITION ��Ӧ�� Unicode Technical Report #15 ���������� Normalization Form D��
getDecomposition()
,
setDecomposition(int)
,
�����ֶ�ֵpublic static final int FULL_DECOMPOSITION
FULL_DECOMPOSITION ��Ӧ�� Unicode Technical Report #15 ���������� Normalization Form KD��
getDecomposition()
,
setDecomposition(int)
,
�����ֶ�ֵ���췽����ϸ��Ϣ |
---|
protected Collator()
getInstance()
������ϸ��Ϣ |
---|
public static Collator getInstance()
Locale.getDefault()
public static Collator getInstance(Locale desiredLocale)
desiredLocale
- ��������Ի�����
Locale
,
ResourceBundle
public abstract int compare(String source, String target)
����һ�αȽϣ��˷�������������ܡ�����ڶ�αȽ����漰������ String���� CollationKey.compareTo ����������ܡ��й�ʹ�� CollationKeys ��ʾ��������� Collator ����������
source
- Դ�ַ�����target
- Ŀ���ַ�����
CollationKey
,
getCollationKey(java.lang.String)
public int compare(Object o1, Object o2)
��ʵ�ֽ����� compare((String)o1, (String)o2)
��
Comparator<Object>
�е� compare
o1
- Ҫ�Ƚϵĵ�һ������o2
- Ҫ�Ƚϵĵڶ�������
ClassCastException
- ��������ǿ��ת��Ϊ String��Comparator
public abstract CollationKey getCollationKey(String source)
source
- ��Ҫ��ת��Ϊ���������ַ�����
CollationKey
,
compare(java.lang.String, java.lang.String)
public boolean equals(String source, String target)
source
- Ҫ�Ƚϵ�Դ�ַ�����target
- Ҫ�Ƚϵ�Ŀ���ַ�����
compare(java.lang.String, java.lang.String)
public int getStrength()
setStrength(int)
,
PRIMARY
,
SECONDARY
,
TERTIARY
,
IDENTICAL
public void setStrength(int newStrength)
newStrength
- �µ� strength ֵ��
IllegalArgumentException
- ����µ� strength ֵ���� PRIMARY��SECONDARY��TERTIARY �� IDENTICAL ֮һ��getStrength()
,
PRIMARY
,
SECONDARY
,
TERTIARY
,
IDENTICAL
public int getDecomposition()
���� decomposition ģʽ������ֵ�ǣ�
setDecomposition(int)
,
NO_DECOMPOSITION
,
CANONICAL_DECOMPOSITION
,
FULL_DECOMPOSITION
public void setDecomposition(int decompositionMode)
decompositionMode
- �µ� decomposition ģʽ��
IllegalArgumentException
- �������ֵ������Ч�� decomposition ģʽ��getDecomposition()
,
NO_DECOMPOSITION
,
CANONICAL_DECOMPOSITION
,
FULL_DECOMPOSITION
public static Locale[] getAvailableLocales()
getInstance
������Ϊ��Щ���Ի��������ѱ��ػ���ʵ���� ���ص�������� Java ����ʱ���Ѱ�װ�� CollatorProvider
ʵ����֧�ֵ����Ի��������ϡ������ٰ���һ����ͬ�� Locale.US
�� Locale ʵ����
Collator
ʵ����public Object clone()
Object
�е� clone
Cloneable
public boolean equals(Object that)
Comparator<Object>
�е� equals
Object
�е� equals
that
- Ҫ��� Collator ���бȽϵ� Collator��
Object.hashCode()
,
Hashtable
public abstract int hashCode()
Object
�е� hashCode
Object.equals(java.lang.Object)
,
Hashtable
|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
��Ȩ���� 2007 Sun Microsystems, Inc. ��������Ȩ���� ����������֤��������������ĵ����·ַ�������