001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.webservices.builder;
018    
019    import javax.xml.namespace.QName;
020    
021    /**
022     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
023     */
024    public final class SchemaTypeKey {
025        public static final String QNAME_SCOPE_COMPLEX_TYPE = "complexType";
026        public static final String QNAME_SCOPE_SIMPLE_TYPE = "simpleType";
027        public static final String QNAME_SCOPE_ELEMENT = "element";
028    
029        private final QName qName;
030        private final String qNameScope;
031        private final boolean isElement;
032        private final boolean isSimpleType;
033        private final boolean isAnonymous;
034    
035        private final QName elementQName;
036    
037    
038        public SchemaTypeKey(QName qName, boolean element, boolean isSimpleType, boolean anonymous, QName elementQName) {
039            assert qName != null;
040            this.qName = qName;
041            isElement = element;
042            this.isSimpleType = isSimpleType;
043            isAnonymous = anonymous;
044            if (isElement) {
045                qNameScope = QNAME_SCOPE_ELEMENT;
046            } else if (isSimpleType) {
047                qNameScope = QNAME_SCOPE_SIMPLE_TYPE;
048            } else {
049                qNameScope = QNAME_SCOPE_COMPLEX_TYPE;
050            }
051            this.elementQName = elementQName;
052        }
053    
054        public QName getqName() {
055            return qName;
056        }
057    
058        public boolean isElement() {
059            return isElement;
060        }
061    
062        public boolean isSimpleType() {
063            return isSimpleType;
064        }
065    
066        public boolean isAnonymous() {
067            return isAnonymous;
068        }
069    
070        public String getqNameScope() {
071            return qNameScope;
072        }
073    
074        public QName getElementQName() {
075            return elementQName;
076        }
077    
078        public int hashCode() {
079            return qName.hashCode();
080        }
081    
082        public boolean equals(Object other) {
083            if (!(other instanceof SchemaTypeKey)) {
084                return false;
085            }
086            SchemaTypeKey key = (SchemaTypeKey) other;
087            return isElement == key.isElement && isSimpleType == key.isSimpleType && isAnonymous == key.isAnonymous && qName.equals(key.qName);
088        }
089    
090        public String toString() {
091            StringBuffer buf = new StringBuffer("\nSchemaTypeKey: scope: ").append(qNameScope);
092            buf.append(" isElement: ").append(isElement);
093            buf.append(" isAnonymous: ").append(isAnonymous);
094            buf.append(" isSimpleType: ").append(isSimpleType);
095            buf.append("\n QName: ").append(qName).append("\n");
096            return buf.toString();
097        }
098    
099    
100    }