01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.uilib.list.util.comparator;
16:
17: import java.io.Serializable;
18: import java.util.Locale;
19:
20: /**
21: * Not-null comparator that compares <code>String</code> values case
22: * insensitive. This comparator is not <code>Locale</code>-specific.
23: */
24: public class IgnoreCaseComparator implements StringComparator,
25: Serializable {
26: public static final IgnoreCaseComparator INSTANCE = new IgnoreCaseComparator();
27:
28: private IgnoreCaseComparator() {
29: }
30:
31: public boolean getIgnoreCase() {
32: return true;
33: }
34:
35: public Locale getLocale() {
36: throw new RuntimeException("Locales not supported");
37: }
38:
39: public int compare(Object o1, Object o2) {
40: return String.CASE_INSENSITIVE_ORDER.compare((String) o1,
41: (String) o2);
42: }
43:
44: public boolean equals(Object obj) {
45: return IgnoreCaseComparator.class.equals(obj.getClass());
46: }
47:
48: public int hashCode() {
49: return 703271433;
50: }
51: }
|