getCollationKey ( )源码实例Demo

java.text.Collator#getCollationKey ( )源码实例Demo

下面列出了java.text.Collator#getCollationKey ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: APITest.java
public final void TestCollationKey( )
{
    logln("testing CollationKey begins...");
    Collator col = null;
    try {
        col = Collator.getInstance(Locale.ROOT);
    } catch (Exception foo) {
        errln("Error : " + foo.getMessage());
        errln("Default collation creation failed.");
    }
    if (col == null) {
        return;
    }

    String test1 = "Abcda", test2 = "abcda";
    logln("Use tertiary comparison level testing ....");
    CollationKey sortk1 = col.getCollationKey(test1);
    CollationKey sortk2 = col.getCollationKey(test2);
    doAssert(sortk1.compareTo(sortk2) > 0,
                "Result should be \"Abcda\" >>> \"abcda\"");
    CollationKey sortk3 = sortk2;
    CollationKey sortkNew = sortk1;
    doAssert(sortk1 != sortk2, "The sort keys should be different");
    doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
    doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
    doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
    doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
    doAssert(sortkNew != sortk3, "The sort keys should be different");
    doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
    doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
    long    cnt1, cnt2;
    byte byteArray1[] = sortk1.toByteArray();
    byte byteArray2[] = sortk2.toByteArray();
    doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
    logln("testing sortkey ends...");
}
 
源代码2 项目: TencentKona-8   文件: APITest.java
public final void TestCollationKey( )
{
    logln("testing CollationKey begins...");
    Collator col = null;
    try {
        col = Collator.getInstance(Locale.ROOT);
    } catch (Exception foo) {
        errln("Error : " + foo.getMessage());
        errln("Default collation creation failed.");
    }
    if (col == null) {
        return;
    }

    String test1 = "Abcda", test2 = "abcda";
    logln("Use tertiary comparison level testing ....");
    CollationKey sortk1 = col.getCollationKey(test1);
    CollationKey sortk2 = col.getCollationKey(test2);
    doAssert(sortk1.compareTo(sortk2) > 0,
                "Result should be \"Abcda\" >>> \"abcda\"");
    CollationKey sortk3 = sortk2;
    CollationKey sortkNew = sortk1;
    doAssert(sortk1 != sortk2, "The sort keys should be different");
    doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
    doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
    doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
    doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
    doAssert(sortkNew != sortk3, "The sort keys should be different");
    doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
    doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
    long    cnt1, cnt2;
    byte byteArray1[] = sortk1.toByteArray();
    byte byteArray2[] = sortk2.toByteArray();
    doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
    logln("testing sortkey ends...");
}
 
源代码3 项目: openjdk-jdk8u   文件: APITest.java
public final void TestCollationKey( )
{
    logln("testing CollationKey begins...");
    Collator col = null;
    try {
        col = Collator.getInstance(Locale.ROOT);
    } catch (Exception foo) {
        errln("Error : " + foo.getMessage());
        errln("Default collation creation failed.");
    }
    if (col == null) {
        return;
    }

    String test1 = "Abcda", test2 = "abcda";
    logln("Use tertiary comparison level testing ....");
    CollationKey sortk1 = col.getCollationKey(test1);
    CollationKey sortk2 = col.getCollationKey(test2);
    doAssert(sortk1.compareTo(sortk2) > 0,
                "Result should be \"Abcda\" >>> \"abcda\"");
    CollationKey sortk3 = sortk2;
    CollationKey sortkNew = sortk1;
    doAssert(sortk1 != sortk2, "The sort keys should be different");
    doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
    doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
    doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
    doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
    doAssert(sortkNew != sortk3, "The sort keys should be different");
    doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
    doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
    long    cnt1, cnt2;
    byte byteArray1[] = sortk1.toByteArray();
    byte byteArray2[] = sortk2.toByteArray();
    doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
    logln("testing sortkey ends...");
}
 
源代码4 项目: openjdk-jdk9   文件: APITest.java
public final void TestCollationKey( )
{
    logln("testing CollationKey begins...");
    Collator col = null;
    try {
        col = Collator.getInstance(Locale.ROOT);
    } catch (Exception foo) {
        errln("Error : " + foo.getMessage());
        errln("Default collation creation failed.");
    }
    if (col == null) {
        return;
    }

    String test1 = "Abcda", test2 = "abcda";
    logln("Use tertiary comparison level testing ....");
    CollationKey sortk1 = col.getCollationKey(test1);
    CollationKey sortk2 = col.getCollationKey(test2);
    doAssert(sortk1.compareTo(sortk2) > 0,
                "Result should be \"Abcda\" >>> \"abcda\"");
    CollationKey sortk3 = sortk2;
    CollationKey sortkNew = sortk1;
    doAssert(sortk1 != sortk2, "The sort keys should be different");
    doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
    doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
    doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
    doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
    doAssert(sortkNew != sortk3, "The sort keys should be different");
    doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
    doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
    long    cnt1, cnt2;
    byte byteArray1[] = sortk1.toByteArray();
    byte byteArray2[] = sortk2.toByteArray();
    doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
    logln("testing sortkey ends...");
}
 
源代码5 项目: jdk8u_jdk   文件: APITest.java
public final void TestCollationKey( )
{
    logln("testing CollationKey begins...");
    Collator col = null;
    try {
        col = Collator.getInstance(Locale.ROOT);
    } catch (Exception foo) {
        errln("Error : " + foo.getMessage());
        errln("Default collation creation failed.");
    }
    if (col == null) {
        return;
    }

    String test1 = "Abcda", test2 = "abcda";
    logln("Use tertiary comparison level testing ....");
    CollationKey sortk1 = col.getCollationKey(test1);
    CollationKey sortk2 = col.getCollationKey(test2);
    doAssert(sortk1.compareTo(sortk2) > 0,
                "Result should be \"Abcda\" >>> \"abcda\"");
    CollationKey sortk3 = sortk2;
    CollationKey sortkNew = sortk1;
    doAssert(sortk1 != sortk2, "The sort keys should be different");
    doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
    doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
    doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
    doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
    doAssert(sortkNew != sortk3, "The sort keys should be different");
    doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
    doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
    long    cnt1, cnt2;
    byte byteArray1[] = sortk1.toByteArray();
    byte byteArray2[] = sortk2.toByteArray();
    doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
    logln("testing sortkey ends...");
}
 
源代码6 项目: tn5250j   文件: KeyConfigure.java
private void supportAplColorCodesInSEU(Collator collator, StringBuffer sb, Set<CollationKey> set) {
	for (Entry<Integer, String> color : colorMap.entrySet()) {
		int keyVal = color.getKey().intValue();
		char c = (char)('\uff00' + keyVal);

	    sb.setLength(0);
	    sb.append("0FF" + Integer.toHexString(keyVal).toUpperCase());
	    sb.append(" - " + c + " - " + color.getValue());
	    CollationKey key = collator.getCollationKey(sb.toString());

	    set.add(key);
	}
}
 
源代码7 项目: airsonic-advanced   文件: MusicIndex.java
public SortableArtist(String name, String sortableName, Collator collator) {
    this.name = name;
    this.sortableName = sortableName;
    collationKey = collator.getCollationKey(sortableName);
}
 
源代码8 项目: dragonwell8_jdk   文件: CollationKeyTestImpl.java
public void run() {
    /** debug: printout the test data
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+": "+sourceData_ja[i]);
    }
    **/
   /*
    * 1. Test the backward compatibility
    *    note: targetData_ja.length is equal to sourceData_ja.length
    */
    Collator myCollator = Collator.getInstance(Locale.JAPAN);
    CollationKey[] keys = new CollationKey[sourceData_ja.length];
    CollationKey[] target_keys = new CollationKey[targetData_ja.length];
    for (int i=0; i<sourceData_ja.length; i++){
            keys[i] = myCollator.getCollationKey(sourceData_ja[i]);
            target_keys[i] = myCollator.getCollationKey(targetData_ja[i]); //used later
    }
    /* Sort the string using CollationKey */
    InsertionSort(keys);
    /** debug: printout the result after sort
    System.out.println("--- After Sorting ---");
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+" :"+keys[i].getSourceString());
    }
    **/
   /*
    * Compare the result using equals method and getSourceString method.
    */
    boolean pass = true;
    for (int i=0; i<sourceData_ja.length; i++){
            /* Comparing using String.equals: in order to use getStringSource() */
            if (! targetData_ja[i].equals(keys[i].getSourceString())){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility "
                              +"while comparing" +targetData_ja[i]+" vs "
                              +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.equals: in order to use equals() */
            if (! target_keys[i].equals(keys[i])){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.equals " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.hashCode(): in order to use hashCode() */
            if (target_keys[i].hashCode() != keys[i].hashCode()){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.hashCode " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.toByteArray(): in order to use toByteArray() */
            byte[] target_bytes = target_keys[i].toByteArray();
            byte[] source_bytes = keys[i].toByteArray();
            for (int j=0; j<target_bytes.length; j++){
                    Byte targetByte = new Byte(target_bytes[j]);
                    Byte sourceByte = new Byte(source_bytes[j]);
                    if (targetByte.compareTo(sourceByte)!=0){
                        throw new RuntimeException("FAILED: CollationKeyTest backward "
                              +"compatibility. Using Byte.compareTo from CollationKey.toByteArray "
                              +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
                    }
            }
    }
    testSubclassMethods();
    testConstructor();
}
 
源代码9 项目: TencentKona-8   文件: CollationKeyTestImpl.java
public void run() {
    /** debug: printout the test data
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+": "+sourceData_ja[i]);
    }
    **/
   /*
    * 1. Test the backward compatibility
    *    note: targetData_ja.length is equal to sourceData_ja.length
    */
    Collator myCollator = Collator.getInstance(Locale.JAPAN);
    CollationKey[] keys = new CollationKey[sourceData_ja.length];
    CollationKey[] target_keys = new CollationKey[targetData_ja.length];
    for (int i=0; i<sourceData_ja.length; i++){
            keys[i] = myCollator.getCollationKey(sourceData_ja[i]);
            target_keys[i] = myCollator.getCollationKey(targetData_ja[i]); //used later
    }
    /* Sort the string using CollationKey */
    InsertionSort(keys);
    /** debug: printout the result after sort
    System.out.println("--- After Sorting ---");
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+" :"+keys[i].getSourceString());
    }
    **/
   /*
    * Compare the result using equals method and getSourceString method.
    */
    boolean pass = true;
    for (int i=0; i<sourceData_ja.length; i++){
            /* Comparing using String.equals: in order to use getStringSource() */
            if (! targetData_ja[i].equals(keys[i].getSourceString())){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility "
                              +"while comparing" +targetData_ja[i]+" vs "
                              +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.equals: in order to use equals() */
            if (! target_keys[i].equals(keys[i])){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.equals " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.hashCode(): in order to use hashCode() */
            if (target_keys[i].hashCode() != keys[i].hashCode()){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.hashCode " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.toByteArray(): in order to use toByteArray() */
            byte[] target_bytes = target_keys[i].toByteArray();
            byte[] source_bytes = keys[i].toByteArray();
            for (int j=0; j<target_bytes.length; j++){
                    Byte targetByte = new Byte(target_bytes[j]);
                    Byte sourceByte = new Byte(source_bytes[j]);
                    if (targetByte.compareTo(sourceByte)!=0){
                        throw new RuntimeException("FAILED: CollationKeyTest backward "
                              +"compatibility. Using Byte.compareTo from CollationKey.toByteArray "
                              +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
                    }
            }
    }
    testSubclassMethods();
    testConstructor();
}
 
源代码10 项目: openjdk-jdk8u   文件: CollationKeyTestImpl.java
public void run() {
    /** debug: printout the test data
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+": "+sourceData_ja[i]);
    }
    **/
   /*
    * 1. Test the backward compatibility
    *    note: targetData_ja.length is equal to sourceData_ja.length
    */
    Collator myCollator = Collator.getInstance(Locale.JAPAN);
    CollationKey[] keys = new CollationKey[sourceData_ja.length];
    CollationKey[] target_keys = new CollationKey[targetData_ja.length];
    for (int i=0; i<sourceData_ja.length; i++){
            keys[i] = myCollator.getCollationKey(sourceData_ja[i]);
            target_keys[i] = myCollator.getCollationKey(targetData_ja[i]); //used later
    }
    /* Sort the string using CollationKey */
    InsertionSort(keys);
    /** debug: printout the result after sort
    System.out.println("--- After Sorting ---");
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+" :"+keys[i].getSourceString());
    }
    **/
   /*
    * Compare the result using equals method and getSourceString method.
    */
    boolean pass = true;
    for (int i=0; i<sourceData_ja.length; i++){
            /* Comparing using String.equals: in order to use getStringSource() */
            if (! targetData_ja[i].equals(keys[i].getSourceString())){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility "
                              +"while comparing" +targetData_ja[i]+" vs "
                              +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.equals: in order to use equals() */
            if (! target_keys[i].equals(keys[i])){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.equals " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.hashCode(): in order to use hashCode() */
            if (target_keys[i].hashCode() != keys[i].hashCode()){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.hashCode " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.toByteArray(): in order to use toByteArray() */
            byte[] target_bytes = target_keys[i].toByteArray();
            byte[] source_bytes = keys[i].toByteArray();
            for (int j=0; j<target_bytes.length; j++){
                    Byte targetByte = new Byte(target_bytes[j]);
                    Byte sourceByte = new Byte(source_bytes[j]);
                    if (targetByte.compareTo(sourceByte)!=0){
                        throw new RuntimeException("FAILED: CollationKeyTest backward "
                              +"compatibility. Using Byte.compareTo from CollationKey.toByteArray "
                              +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
                    }
            }
    }
    testSubclassMethods();
    testConstructor();
}
 
源代码11 项目: airsonic   文件: MusicIndex.java
public SortableArtist(String name, String sortableName, Collator collator) {
    this.name = name;
    this.sortableName = sortableName;
    collationKey = collator.getCollationKey(sortableName);
}
 
源代码12 项目: openjdk-jdk9   文件: CollationKeyTestImpl.java
public void run() {
    /** debug: printout the test data
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+": "+sourceData_ja[i]);
    }
    **/
   /*
    * 1. Test the backward compatibility
    *    note: targetData_ja.length is equal to sourceData_ja.length
    */
    Collator myCollator = Collator.getInstance(Locale.JAPAN);
    CollationKey[] keys = new CollationKey[sourceData_ja.length];
    CollationKey[] target_keys = new CollationKey[targetData_ja.length];
    for (int i=0; i<sourceData_ja.length; i++){
            keys[i] = myCollator.getCollationKey(sourceData_ja[i]);
            target_keys[i] = myCollator.getCollationKey(targetData_ja[i]); //used later
    }
    /* Sort the string using CollationKey */
    InsertionSort(keys);
    /** debug: printout the result after sort
    System.out.println("--- After Sorting ---");
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+" :"+keys[i].getSourceString());
    }
    **/
   /*
    * Compare the result using equals method and getSourceString method.
    */
    boolean pass = true;
    for (int i=0; i<sourceData_ja.length; i++){
            /* Comparing using String.equals: in order to use getStringSource() */
            if (! targetData_ja[i].equals(keys[i].getSourceString())){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility "
                              +"while comparing" +targetData_ja[i]+" vs "
                              +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.equals: in order to use equals() */
            if (! target_keys[i].equals(keys[i])){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.equals " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.hashCode(): in order to use hashCode() */
            if (target_keys[i].hashCode() != keys[i].hashCode()){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.hashCode " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.toByteArray(): in order to use toByteArray() */
            byte[] target_bytes = target_keys[i].toByteArray();
            byte[] source_bytes = keys[i].toByteArray();
            for (int j=0; j<target_bytes.length; j++){
                    Byte targetByte = new Byte(target_bytes[j]);
                    Byte sourceByte = new Byte(source_bytes[j]);
                    if (targetByte.compareTo(sourceByte)!=0){
                        throw new RuntimeException("FAILED: CollationKeyTest backward "
                              +"compatibility. Using Byte.compareTo from CollationKey.toByteArray "
                              +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
                    }
            }
    }
    testSubclassMethods();
    testConstructor();
}
 
源代码13 项目: jdk8u_jdk   文件: CollationKeyTestImpl.java
public void run() {
    /** debug: printout the test data
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+": "+sourceData_ja[i]);
    }
    **/
   /*
    * 1. Test the backward compatibility
    *    note: targetData_ja.length is equal to sourceData_ja.length
    */
    Collator myCollator = Collator.getInstance(Locale.JAPAN);
    CollationKey[] keys = new CollationKey[sourceData_ja.length];
    CollationKey[] target_keys = new CollationKey[targetData_ja.length];
    for (int i=0; i<sourceData_ja.length; i++){
            keys[i] = myCollator.getCollationKey(sourceData_ja[i]);
            target_keys[i] = myCollator.getCollationKey(targetData_ja[i]); //used later
    }
    /* Sort the string using CollationKey */
    InsertionSort(keys);
    /** debug: printout the result after sort
    System.out.println("--- After Sorting ---");
    for (int i=0; i<sourceData_ja.length; i++){
            System.out.println(i+" :"+keys[i].getSourceString());
    }
    **/
   /*
    * Compare the result using equals method and getSourceString method.
    */
    boolean pass = true;
    for (int i=0; i<sourceData_ja.length; i++){
            /* Comparing using String.equals: in order to use getStringSource() */
            if (! targetData_ja[i].equals(keys[i].getSourceString())){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility "
                              +"while comparing" +targetData_ja[i]+" vs "
                              +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.equals: in order to use equals() */
            if (! target_keys[i].equals(keys[i])){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.equals " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.hashCode(): in order to use hashCode() */
            if (target_keys[i].hashCode() != keys[i].hashCode()){
                    throw new RuntimeException("FAILED: CollationKeyTest backward compatibility."
                              +" Using CollationKey.hashCode " +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
            }
            /* Comparing using CollaionKey.toByteArray(): in order to use toByteArray() */
            byte[] target_bytes = target_keys[i].toByteArray();
            byte[] source_bytes = keys[i].toByteArray();
            for (int j=0; j<target_bytes.length; j++){
                    Byte targetByte = new Byte(target_bytes[j]);
                    Byte sourceByte = new Byte(source_bytes[j]);
                    if (targetByte.compareTo(sourceByte)!=0){
                        throw new RuntimeException("FAILED: CollationKeyTest backward "
                              +"compatibility. Using Byte.compareTo from CollationKey.toByteArray "
                              +targetData_ja[i]
                              +" vs " +keys[i].getSourceString());
                    }
            }
    }
    testSubclassMethods();
    testConstructor();
}
 
源代码14 项目: subsonic   文件: MusicIndex.java
public SortableArtist(String name, String sortableName, Collator collator) {
    this.name = name;
    this.sortableName = sortableName;
    collationKey = collator.getCollationKey(sortableName);
}
 
源代码15 项目: tn5250j   文件: KeyConfigure.java
private void loadList(String which) {

      lm.clear();
      lm.removeAllElements();


      if (which.equals(LangTool.getString("key.labelKeys"))) {
        Vector<KeyDescription> lk = new Vector<KeyDescription>(keyMnemonicResolver.getMnemonics().length);
        for (int x = 0; x < keyMnemonicResolver.getMnemonics().length; x++) {
          lk.addElement(new KeyDescription(LangTool.getString("key."+ keyMnemonicResolver.getMnemonics()[x]),x));
         }

         Collections.sort(lk, new KeyDescriptionCompare());

        for (int x = 0; x < keyMnemonicResolver.getMnemonics().length; x++) {
            lm.addElement(lk.get(x));
         }
         macros = false;
         special = false;
      }
      else {
         if (which.equals(LangTool.getString("key.labelMacros"))) {
            Vector<String> macrosVector = new Vector<String>();
            if (macrosList != null)
               for (int x = 0; x < macrosList.length; x++) {
                  macrosVector.add(macrosList[x]);
               }
            scriptDir("scripts",macrosVector);
            loadListModel(lm,macrosVector,null,0);
            macros = true;
            special = false;
         }
         else {

            // we will use a collator here so that we can take advantage of the locales
            Collator collator = Collator.getInstance();
            CollationKey key = null;
            StringBuffer sb = new StringBuffer();

            Set<CollationKey> set = new TreeSet<CollationKey>();

            supportAplColorCodesInSEU(collator, sb, set);

            for (int x =0;x < 256; x++) {
               char c = codePage.ebcdic2uni(x);
               char ac = codePage.ebcdic2uni(x);
               if (!Character.isISOControl(c)) {
                  sb.setLength(0);
                  if (Integer.toHexString(ac).length() == 1){
                     sb.append("0x0" + Integer.toHexString(ac).toUpperCase());
                  }
                  else {
                     sb.append("0x" + Integer.toHexString(ac).toUpperCase());
                  }

                  sb.append(" - " + c + " - " + getUnicodeString(c));
                  key = collator.getCollationKey(sb.toString());

                  set.add(key);
               }
            }

            Iterator<CollationKey> iterator = set.iterator();
            while (iterator.hasNext()) {
               CollationKey keyc = iterator.next();
               lm.addElement(keyc.getSourceString());
            }

            macros = false;
            special = true;

         }
      }
      if (!lm.isEmpty())
         functions.setSelectedIndex(0);
   }
 
源代码16 项目: j2objc   文件: CollatorTest.java
public void test_stackCorruption() throws Exception {
    // This used to crash Android.
    Collator mColl = Collator.getInstance();
    mColl.setStrength(Collator.PRIMARY);
    mColl.getCollationKey("2d294f2d3739433565147655394f3762f3147312d3731641452f310");
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 方法所在类