Code example for RuleBasedCollator

Methods: getCollationKey

0
		CollationKey key1 = collator.getCollationKey("abc");
		byte[] bytes = key1.toByteArray();
		assertTrue("Not enough bytes", bytes.length >= 3);
 
		try { 
			collator = new RuleBasedCollator("= 1 , 2 ; 3 , 4 < 5 ; 6 , 7");
		} catch (ParseException e) {
			fail("ParseException");
			return; 
		} 
		bytes = collator.getCollationKey("1234567").toByteArray();
		/* 
		 * CollationElementIterator it = 
		 * ((RuleBasedCollator)collator).getCollationElementIterator("1234567"); 
		 * int order; while ((order = it.next()) != 
		 * CollationElementIterator.NULLORDER) { 
		 * System.out.println(Integer.toHexString(order)); } for (int i=0; i<bytes.length; 
		 * i+=2) { System.out.print(Integer.toHexString(bytes[i]) + 
		 * Integer.toHexString(bytes[i+1]) + " "); } System.out.println(); 
		 */ 
Contextual code suggestions in your IDE  Get Codota for Java