1. package org.apache.xml.utils;
  2. /**
  3. * <meta name="usage" content="internal"/>
  4. * Simple class for fast lookup of char values, when used with
  5. * hashtables. You can set the char, then use it as a key.
  6. */
  7. public class CharKey extends Object
  8. {
  9. /** String value */
  10. private char m_char;
  11. /**
  12. * Constructor CharKey
  13. *
  14. * @param key char value of this object.
  15. */
  16. public CharKey(char key)
  17. {
  18. m_char = key;
  19. }
  20. /**
  21. * Default constructor for a CharKey.
  22. *
  23. * @param key char value of this object.
  24. */
  25. public CharKey()
  26. {
  27. }
  28. /**
  29. * Get the hash value of the character.
  30. *
  31. * @return hash value of the character.
  32. */
  33. public final void setChar(char c)
  34. {
  35. m_char = c;
  36. }
  37. /**
  38. * Get the hash value of the character.
  39. *
  40. * @return hash value of the character.
  41. */
  42. public final int hashCode()
  43. {
  44. return (int)m_char;
  45. }
  46. /**
  47. * Override of equals() for this object
  48. *
  49. * @param obj to compare to
  50. *
  51. * @return True if this object equals this string value
  52. */
  53. public final boolean equals(Object obj)
  54. {
  55. return ((CharKey)obj).m_char == m_char;
  56. }
  57. }