]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_4_2-src/main/classes/localespi/src/com/ibm/icu/impl/jdkadapter/CollationKeyICU.java
go
[Dictionary.git] / jars / icu4j-4_4_2-src / main / classes / localespi / src / com / ibm / icu / impl / jdkadapter / CollationKeyICU.java
1 /*\r
2  *******************************************************************************\r
3  * Copyright (C) 2008, International Business Machines Corporation and         *\r
4  * others. All Rights Reserved.                                                *\r
5  *******************************************************************************\r
6  */\r
7 package com.ibm.icu.impl.jdkadapter;\r
8 \r
9 import com.ibm.icu.text.CollationKey;\r
10 \r
11 /**\r
12  * CollationKeyICU is an adapter class which wraps ICU4J CollationKey and\r
13  * implements java.text.CollationKey APIs.\r
14  */\r
15 public class CollationKeyICU extends java.text.CollationKey {\r
16 \r
17     private CollationKey fIcuCollKey;\r
18 \r
19     private CollationKeyICU(CollationKey icuCollKey) {\r
20         super(icuCollKey.getSourceString());\r
21         fIcuCollKey = icuCollKey;\r
22     }\r
23 \r
24     public static java.text.CollationKey wrap(CollationKey icuCollKey) {\r
25         return new CollationKeyICU(icuCollKey);\r
26     }\r
27 \r
28     public CollationKey unwrap() {\r
29         return fIcuCollKey;\r
30     }\r
31 \r
32     @Override\r
33     public int compareTo(java.text.CollationKey target) {\r
34         if (target instanceof CollationKeyICU) {\r
35             return fIcuCollKey.compareTo(((CollationKeyICU)target).fIcuCollKey);\r
36         }\r
37         return 0;\r
38     }\r
39 \r
40     @Override\r
41     public String getSourceString() {\r
42         return fIcuCollKey.getSourceString();\r
43     }\r
44 \r
45     @Override\r
46     public byte[] toByteArray() {\r
47         return fIcuCollKey.toByteArray();\r
48     }\r
49 \r
50     @Override\r
51     public boolean equals(Object obj) {\r
52         if (obj instanceof CollationKeyICU) {\r
53             return ((CollationKeyICU)obj).fIcuCollKey.equals(fIcuCollKey);\r
54         }\r
55         return false;\r
56     }\r
57 \r
58     @Override\r
59     public int hashCode() {\r
60         return fIcuCollKey.hashCode();\r
61     }\r
62 }\r