KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xalan > internal > xsltc > compiler > QName


1 /*
2  * Copyright 2001-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: QName.java,v 1.6 2004/02/16 22:24:29 minchau Exp $
18  */

19
20 package com.sun.org.apache.xalan.internal.xsltc.compiler;
21
22 /**
23  * @author Jacek Ambroziak
24  * @author Santiago Pericas-Geertsen
25  * @author Morten Jorgensen
26  */

27 final class QName {
28     private final String JavaDoc _localname;
29     private String JavaDoc _prefix;
30     private String JavaDoc _namespace;
31     private String JavaDoc _stringRep;
32     private int _hashCode;
33
34     public QName(String JavaDoc namespace, String JavaDoc prefix, String JavaDoc localname) {
35     _namespace = namespace;
36     _prefix = prefix;
37     _localname = localname;
38
39     _stringRep =
40         (namespace != null && !namespace.equals(Constants.EMPTYSTRING)) ?
41         (namespace + ':' + localname) : localname;
42
43     _hashCode = _stringRep.hashCode() + 19; // cached for speed
44
}
45
46     public void clearNamespace() {
47     _namespace = Constants.EMPTYSTRING;
48     }
49
50     public String JavaDoc toString() {
51     return _stringRep;
52     }
53
54     public String JavaDoc getStringRep() {
55     return _stringRep;
56     }
57
58     public boolean equals(Object JavaDoc other) {
59     return (this == other);
60     }
61
62     public String JavaDoc getLocalPart() {
63     return _localname;
64     }
65
66     public String JavaDoc getNamespace() {
67     return _namespace;
68     }
69
70     public String JavaDoc getPrefix() {
71     return _prefix;
72     }
73
74     public int hashCode() {
75     return _hashCode;
76     }
77
78     public String JavaDoc dump() {
79     return new String JavaDoc("QName: " + _namespace + "(" + _prefix + "):"
80         + _localname);
81     }
82 }
83
Popular Tags