KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > axis > builder > SchemaTypeKey


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.axis.builder;
18
19 import javax.xml.namespace.QName JavaDoc;
20
21 /**
22  * @version $Rev: $ $Date: $
23  */

24 public final class SchemaTypeKey {
25     public static final String JavaDoc QNAME_SCOPE_COMPLEX_TYPE = "complexType";
26     public static final String JavaDoc QNAME_SCOPE_SIMPLE_TYPE = "simpleType";
27     public static final String JavaDoc QNAME_SCOPE_ELEMENT = "element";
28
29     private final QName JavaDoc qName;
30     private final String JavaDoc qNameScope;
31     private final boolean isElement;
32     private final boolean isSimpleType;
33     private final boolean isAnonymous;
34
35     private final QName JavaDoc elementQName;
36
37
38     public SchemaTypeKey(QName JavaDoc qName, boolean element, boolean isSimpleType, boolean anonymous, QName JavaDoc elementQName) {
39         assert qName != null;
40         this.qName = qName;
41         isElement = element;
42         this.isSimpleType = isSimpleType;
43         isAnonymous = anonymous;
44         if (isElement) {
45             qNameScope = QNAME_SCOPE_ELEMENT;
46         } else if (isSimpleType) {
47             qNameScope = QNAME_SCOPE_SIMPLE_TYPE;
48         } else {
49             qNameScope = QNAME_SCOPE_COMPLEX_TYPE;
50         }
51         this.elementQName = elementQName;
52     }
53
54     public QName JavaDoc getqName() {
55         return qName;
56     }
57
58     public boolean isElement() {
59         return isElement;
60     }
61
62     public boolean isSimpleType() {
63         return isSimpleType;
64     }
65
66     public boolean isAnonymous() {
67         return isAnonymous;
68     }
69
70     public String JavaDoc getqNameScope() {
71         return qNameScope;
72     }
73
74     public QName JavaDoc getElementQName() {
75         return elementQName;
76     }
77
78     public int hashCode() {
79         return qName.hashCode();
80     }
81
82     public boolean equals(Object JavaDoc other) {
83         if (!(other instanceof SchemaTypeKey)) {
84             return false;
85         }
86         SchemaTypeKey key = (SchemaTypeKey) other;
87         return isElement == key.isElement && isSimpleType == key.isSimpleType && isAnonymous == key.isAnonymous && qName.equals(key.qName);
88     }
89
90     public String JavaDoc toString() {
91         StringBuffer JavaDoc buf = new StringBuffer JavaDoc("\nSchemaTypeKey: scope: ").append(qNameScope);
92         buf.append(" isElement: ").append(isElement);
93         buf.append(" isAnonymous: ").append(isAnonymous);
94         buf.append(" isSimpleType: ").append(isSimpleType);
95         buf.append("\n QName: ").append(qName).append("\n");
96         return buf.toString();
97     }
98
99
100 }
101
Popular Tags