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