1 7 8 20 21 package java.text; 22 23 27 28 final class RuleBasedCollationKey extends CollationKey { 29 39 public int compareTo(CollationKey target) 40 { 41 int result = key.compareTo(((RuleBasedCollationKey )(target)).key); 42 if (result <= Collator.LESS) 43 return Collator.LESS; 44 else if (result >= Collator.GREATER) 45 return Collator.GREATER; 46 return Collator.EQUAL; 47 } 48 49 57 public boolean equals(Object target) { 58 if (this == target) return true; 59 if (target == null || !getClass().equals(target.getClass())) { 60 return false; 61 } 62 RuleBasedCollationKey other = (RuleBasedCollationKey )target; 63 return key.equals(other.key); 64 } 65 66 74 public int hashCode() { 75 return (key.hashCode()); 76 } 77 78 84 public byte[] toByteArray() { 85 86 char[] src = key.toCharArray(); 87 byte[] dest = new byte[ 2*src.length ]; 88 int j = 0; 89 for( int i=0; i<src.length; i++ ) { 90 dest[j++] = (byte)(src[i] >>> 8); 91 dest[j++] = (byte)(src[i] & 0x00ff); 92 } 93 return dest; 94 } 95 96 99 RuleBasedCollationKey(String source, String key) { 100 super(source); 101 this.key = key; 102 } 103 private String key = null; 104 105 } 106 107 108 109 | Popular Tags |