01: /*
02: * CaseInsensitiveString.java
03: *
04: * Copyright (c) 2003 Rimfaxe ApS (www.rimfaxe.com).
05: * All rights reserved.
06: *
07: * This package is written by Lars Andersen <lars@rimfaxe.com>
08: * and licensed by Rimfaxe ApS.
09: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: *
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: *
17: * 2. Redistributions in binary form must reproduce the above copyright
18: * notice, this list of conditions and the following disclaimer in
19: * the documentation and/or other materials provided with the
20: * distribution.
21: *
22: * 3. The end-user documentation included with the redistribution, if
23: * any, must include the following acknowlegement:
24: * "This product includes software developed by Rimfaxe ApS
25: (www.rimfaxe.com)"
26: * Alternately, this acknowlegement may appear in the software itself,
27: * if and wherever such third-party acknowlegements normally appear.
28: *
29: * 4. The names "Rimfaxe", "Rimfaxe Software", "Lars Andersen" and
30: * "Rimfaxe WebServer" must not be used to endorse or promote products
31: * derived from this software without prior written permission. For written
32: * permission, please contact info@rimfaxe.com
33: *
34: * 5. Products derived from this software may not be called "Rimfaxe"
35: * nor may "Rimfaxe" appear in their names without prior written
36: * permission of the Rimfaxe ApS.
37: *
38: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
39: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
42: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48: * SUCH DAMAGE.
49: *
50: */
51:
52: package com.rimfaxe.util;
53:
54: /**
55: *
56: * @author Lars Andersen
57: */
58: public class CaseInsensitiveString {
59: String value = "";
60:
61: /** Creates a new instance of CaseInsensitiveString */
62: public CaseInsensitiveString(String value) {
63: this .value = value;
64: }
65:
66: public boolean equals(Object o) {
67: if (o.getClass().getName().equalsIgnoreCase(
68: "com.rimfaxe.util.CaseInsensitiveString")) {
69: CaseInsensitiveString cis = (CaseInsensitiveString) o;
70: if (cis.toString().equalsIgnoreCase(this .value))
71: return true;
72: }
73:
74: return false;
75: }
76:
77: public int hashCode() {
78: return value.toLowerCase().hashCode();
79: }
80:
81: public String toString() {
82: return value;
83: }
84: }
|