1. /*
  2. * Copyright 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. package com.sun.org.apache.xerces.internal.util;
  17. /**
  18. * <p>A structure that represents an error code, characterized by
  19. * a domain and a message key.</p>
  20. *
  21. * @author Naela Nissar, IBM
  22. *
  23. * @version $Id: XMLErrorCode.java,v 1.1.1.1 2004/05/04 10:22:36 vk112360 Exp $
  24. */
  25. public class XMLErrorCode {
  26. //
  27. // Data
  28. //
  29. /** error domain **/
  30. private String fDomain;
  31. /** message key **/
  32. private String fKey;
  33. /**
  34. * <p>Constructs an XMLErrorCode with the given domain and key.</p>
  35. *
  36. * @param domain The error domain.
  37. * @param key The key of the error message.
  38. */
  39. public XMLErrorCode(String domain, String key) {
  40. fDomain = domain;
  41. fKey = key;
  42. }
  43. /**
  44. * <p>Convenience method to set the values of an XMLErrorCode.</p>
  45. *
  46. * @param domain The error domain.
  47. * @param key The key of the error message.
  48. */
  49. public void setValues(String domain, String key) {
  50. fDomain = domain;
  51. fKey = key;
  52. }
  53. /**
  54. * <p>Indicates whether some other object is equal to this XMLErrorCode.</p>
  55. *
  56. * @param obj the object with which to compare.
  57. */
  58. public boolean equals(Object obj) {
  59. if (!(obj instanceof XMLErrorCode))
  60. return false;
  61. XMLErrorCode err = (XMLErrorCode) obj;
  62. return (fDomain.equals(err.fDomain) && fKey.equals(err.fKey));
  63. }
  64. /**
  65. * <p>Returns a hash code value for this XMLErrorCode.</p>
  66. *
  67. * @return a hash code value for this XMLErrorCode.
  68. */
  69. public int hashCode() {
  70. return fDomain.hashCode() + fKey.hashCode();
  71. }
  72. }