1 7 package com.ibm.icu.util; 8 9 import com.ibm.icu.lang.UCharacter; 10 11 17 public class CaseInsensitiveString { 18 19 private String string; 20 21 private int hash = 0; 22 27 public CaseInsensitiveString(String s) { 28 string = s; 29 } 30 35 public String getString() { 36 return string; 37 } 38 43 public boolean equals(Object o) { 44 try { 45 return string.equalsIgnoreCase(((CaseInsensitiveString)o).string); 46 } catch (ClassCastException e) { 47 try { 48 return string.equalsIgnoreCase((String )o); 49 } catch (ClassCastException e2) { 50 return false; 51 } 52 } 53 } 54 55 60 public int hashCode() { 61 if (hash == 0) { 62 hash = UCharacter.foldCase(string, true).hashCode(); 63 } 64 return hash; 65 } 66 70 public String toString() { 71 return string; 72 } 73 } 74 | Popular Tags |