Java Code Examples for java.text.CollationKey#toByteArray()
The following examples show how to use
java.text.CollationKey#toByteArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APITest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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..."); }
Example 2
Source File: Collator.java From adaptive-radix-tree with MIT License | 5 votes |
@Test public void testICU(){ String str = "hello"; java.text.Collator col = java.text.Collator.getInstance(Locale.US);; CollationKey ck = col.getCollationKey(str); byte[] bytes = ck.toByteArray(); System.out.println("collation key bytes length: " + bytes.length); System.out.println("collation key bytes: " + Arrays.toString(bytes)); System.out.println("collation key as string:" + new String(bytes)); System.out.println("original string: " + Arrays.toString(str.getBytes())); }
Example 3
Source File: APITest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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..."); }
Example 4
Source File: APITest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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..."); }
Example 5
Source File: APITest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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..."); }
Example 6
Source File: APITest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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..."); }