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 com.sun.org.apache.xml.internal.utils;
  20. /**
  21. * Simple class for fast lookup of char values, when used with
  22. * hashtables. You can set the char, then use it as a key.
  23. * @xsl.usage internal
  24. */
  25. public class CharKey extends Object
  26. {
  27. /** String value */
  28. private char m_char;
  29. /**
  30. * Constructor CharKey
  31. *
  32. * @param key char value of this object.
  33. */
  34. public CharKey(char key)
  35. {
  36. m_char = key;
  37. }
  38. /**
  39. * Default constructor for a CharKey.
  40. *
  41. * @param key char value of this object.
  42. */
  43. public CharKey()
  44. {
  45. }
  46. /**
  47. * Get the hash value of the character.
  48. *
  49. * @return hash value of the character.
  50. */
  51. public final void setChar(char c)
  52. {
  53. m_char = c;
  54. }
  55. /**
  56. * Get the hash value of the character.
  57. *
  58. * @return hash value of the character.
  59. */
  60. public final int hashCode()
  61. {
  62. return (int)m_char;
  63. }
  64. /**
  65. * Override of equals() for this object
  66. *
  67. * @param obj to compare to
  68. *
  69. * @return True if this object equals this string value
  70. */
  71. public final boolean equals(Object obj)
  72. {
  73. return ((CharKey)obj).m_char == m_char;
  74. }
  75. }