12ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* GENERATED SOURCE. DO NOT MODIFY. */ 2f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// © 2016 and later: Unicode, Inc. and others. 3f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html#License 42ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/** 52ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 62ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Copyright (C) 2001-2013, International Business Machines Corporation and * 72ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * others. All Rights Reserved. * 82ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 92ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpackage android.icu.util; 112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.lang.UCharacter; 132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/** 152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * A string used as a key in java.util.Hashtable and other 162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * collections. It retains case information, but its equals() and 172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * hashCode() methods ignore case. 18836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide Only a subset of ICU is exposed in Android 192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpublic class CaseInsensitiveString { 212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private String string; 232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private int hash = 0; 252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private String folded = null; 272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static String foldCase(String foldee) 292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return UCharacter.foldCase(foldee, true); 312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private void getFolded() 342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (folded == null) { 362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller folded = foldCase(string); 372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs an CaseInsentiveString object from the given string 422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param s The string to construct this object from 432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public CaseInsensitiveString(String s) { 452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller string = s; 462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * returns the underlying string 492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @return String 502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public String getString() { 522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return string; 532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Compare the object with this 562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param o Object to compare this object with 572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public boolean equals(Object o) { 592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (o == null) { 602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return false; 612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (this == o) { 632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return true; 642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (o instanceof CaseInsensitiveString) { 662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller getFolded(); 672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller CaseInsensitiveString cis = (CaseInsensitiveString) o; 682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller cis.getFolded(); 692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return folded.equals(cis.folded); 702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return false; 722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Returns the hashCode of this object 762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @return int hashcode 772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public int hashCode() { 792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller getFolded(); 802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (hash == 0) { 822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller hash = folded.hashCode(); 832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return hash; 862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Overrides superclass method 902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public String toString() { 922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return string; 932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller} 95