KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xml > utils > CharKey


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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  */

16 /*
17  * $Id: CharKey.java,v 1.4 2004/02/17 04:21:14 minchau Exp $
18  */

19 package org.apache.xml.utils;
20
21 /**
22  * Simple class for fast lookup of char values, when used with
23  * hashtables. You can set the char, then use it as a key.
24  * @xsl.usage internal
25  */

26 public class CharKey extends Object JavaDoc
27 {
28
29   /** String value */
30   private char m_char;
31
32   /**
33    * Constructor CharKey
34    *
35    * @param key char value of this object.
36    */

37   public CharKey(char key)
38   {
39     m_char = key;
40   }
41   
42   /**
43    * Default constructor for a CharKey.
44    *
45    * @param key char value of this object.
46    */

47   public CharKey()
48   {
49   }
50   
51   /**
52    * Get the hash value of the character.
53    *
54    * @return hash value of the character.
55    */

56   public final void setChar(char c)
57   {
58     m_char = c;
59   }
60
61
62
63   /**
64    * Get the hash value of the character.
65    *
66    * @return hash value of the character.
67    */

68   public final int hashCode()
69   {
70     return (int)m_char;
71   }
72
73   /**
74    * Override of equals() for this object
75    *
76    * @param obj to compare to
77    *
78    * @return True if this object equals this string value
79    */

80   public final boolean equals(Object JavaDoc obj)
81   {
82     return ((CharKey)obj).m_char == m_char;
83   }
84 }
85
Popular Tags