KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > util > XMLErrorCode


1 /*
2  * Copyright 2004,2005 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 package org.apache.xerces.util;
18
19 /**
20  * <p>A structure that represents an error code, characterized by
21  * a domain and a message key.</p>
22  *
23  * @author Naela Nissar, IBM
24  *
25  * @version $Id: XMLErrorCode.java,v 1.2 2005/05/15 20:07:38 mrglavas Exp $
26  */

27 final class XMLErrorCode {
28
29     //
30
// Data
31
//
32

33     /** error domain **/
34     private String JavaDoc fDomain;
35     
36     /** message key **/
37     private String JavaDoc fKey;
38     
39     /**
40      * <p>Constructs an XMLErrorCode with the given domain and key.</p>
41      *
42      * @param domain The error domain.
43      * @param key The key of the error message.
44      */

45     public XMLErrorCode(String JavaDoc domain, String JavaDoc key) {
46         fDomain = domain;
47         fKey = key;
48     }
49     
50     /**
51      * <p>Convenience method to set the values of an XMLErrorCode.</p>
52      *
53      * @param domain The error domain.
54      * @param key The key of the error message.
55      */

56     public void setValues(String JavaDoc domain, String JavaDoc key) {
57         fDomain = domain;
58         fKey = key;
59     }
60
61     /**
62      * <p>Indicates whether some other object is equal to this XMLErrorCode.</p>
63      *
64      * @param obj the object with which to compare.
65      */

66     public boolean equals(Object JavaDoc obj) {
67         if (!(obj instanceof XMLErrorCode))
68             return false;
69         XMLErrorCode err = (XMLErrorCode) obj;
70         return (fDomain.equals(err.fDomain) && fKey.equals(err.fKey));
71     }
72
73     /**
74      * <p>Returns a hash code value for this XMLErrorCode.</p>
75      *
76      * @return a hash code value for this XMLErrorCode.
77      */

78     public int hashCode() {
79         return fDomain.hashCode() + fKey.hashCode();
80     }
81 }
Popular Tags