1/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements.  See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22package com.sun.org.apache.xalan.internal.xsltc.compiler;
23
24/**
25 * @author Jacek Ambroziak
26 * @author Santiago Pericas-Geertsen
27 * @author Morten Jorgensen
28 */
29final class QName {
30    private final String _localname;
31    private String _prefix;
32    private String _namespace;
33    private String _stringRep;
34    private int    _hashCode;
35
36    public QName(String namespace, String prefix, String localname) {
37        _namespace = namespace;
38        _prefix    = prefix;
39        _localname = localname;
40
41        _stringRep =
42            (namespace != null && !namespace.equals(Constants.EMPTYSTRING)) ?
43            (namespace + ':' + localname) : localname;
44
45        _hashCode  = _stringRep.hashCode() + 19; // cached for speed
46    }
47
48    public void clearNamespace() {
49        _namespace = Constants.EMPTYSTRING;
50    }
51
52    public String toString() {
53        return _stringRep;
54    }
55
56    public String getStringRep() {
57        return _stringRep;
58    }
59
60    public boolean equals(Object other) {
61        return (this == other)
62                   || (other instanceof QName
63                           && _stringRep.equals(((QName) other).getStringRep()));
64    }
65
66    public String getLocalPart() {
67        return _localname;
68    }
69
70    public String getNamespace() {
71        return _namespace;
72    }
73
74    public String getPrefix() {
75        return _prefix;
76    }
77
78    public int hashCode() {
79        return _hashCode;
80    }
81
82    public String dump() {
83        return "QName: " + _namespace + "(" + _prefix + "):" + _localname;
84    }
85}
86