KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > message > PrefixedQName


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 package org.apache.axis.message;
18
19 import javax.xml.namespace.QName JavaDoc;
20 import javax.xml.soap.Name JavaDoc;
21
22 public class PrefixedQName implements Name JavaDoc {
23     /** comment/shared empty string */
24     private static final String JavaDoc emptyString = "".intern();
25     
26     private String JavaDoc prefix;
27     private QName JavaDoc qName;
28     
29     public PrefixedQName(String JavaDoc uri, String JavaDoc localName, String JavaDoc pre) {
30         qName = new QName JavaDoc(uri, localName);
31         prefix = (pre == null)
32                             ? emptyString
33                             : pre.intern();
34     }
35
36     public PrefixedQName(QName JavaDoc qname) {
37         this.qName = qname;
38         prefix = emptyString;
39     }
40
41     public String JavaDoc getLocalName() {
42         return qName.getLocalPart();
43     }
44     
45     public String JavaDoc getQualifiedName() {
46         StringBuffer JavaDoc buf = new StringBuffer JavaDoc(prefix);
47         if(prefix != emptyString)
48             buf.append(':');
49         buf.append(qName.getLocalPart());
50         return buf.toString();
51     }
52     
53     public String JavaDoc getURI() {
54         return qName.getNamespaceURI();
55     }
56     
57     public String JavaDoc getPrefix() {
58         return prefix;
59     }
60     public boolean equals(Object JavaDoc obj) {
61         if (obj == this) {
62             return true;
63         }
64         if (!(obj instanceof PrefixedQName)) {
65             return false;
66         }
67         if (!qName.equals(((PrefixedQName)obj).qName)) {
68             return false;
69         }
70         if (prefix == ((PrefixedQName) obj).prefix) {
71             return true;
72         }
73         return false;
74     }
75
76     public int hashCode() {
77         return prefix.hashCode() + qName.hashCode();
78     }
79     
80     public String JavaDoc toString() {
81         return qName.toString();
82     }
83 }
84
Popular Tags