KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > types > Notation


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 package org.apache.axis.types;
17
18 import org.apache.axis.Constants;
19 import org.apache.axis.description.AttributeDesc;
20 import org.apache.axis.description.ElementDesc;
21 import org.apache.axis.description.FieldDesc;
22 import org.apache.axis.description.TypeDesc;
23
24 /**
25  * Custom class for supporting XSD data type NOTATION.
26  *
27  * @author Davanum Srinivas <dims@yahoo.com>
28  * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#element-notation">XML Schema Part 1: 3.12 Notation Declarations</a>
29  */

30
31 public class Notation implements java.io.Serializable JavaDoc {
32     NCName name;
33     URI publicURI;
34     URI systemURI;
35
36     public Notation() {
37     }
38
39     public Notation(NCName name, URI publicURI, URI systemURI) {
40         this.name = name;
41         this.publicURI = publicURI;
42         this.systemURI = systemURI;
43     }
44
45     public NCName getName() {
46         return name;
47     }
48
49     public void setName(NCName name) {
50         this.name = name;
51     }
52
53     public URI getPublic() {
54         return publicURI;
55     }
56
57     public void setPublic(URI publicURI) {
58         this.publicURI = publicURI;
59     }
60
61     public URI getSystem() {
62         return systemURI;
63     }
64
65     public void setSystem(URI systemURI) {
66         this.systemURI = systemURI;
67     }
68
69     public boolean equals(Object JavaDoc obj) {
70         if (obj == null || !(obj instanceof Notation))
71             return false;
72         Notation other = (Notation) obj;
73         if (name == null) {
74             if (other.getName() != null) {
75                 return false;
76             }
77         } else if (!name.equals(other.getName())) {
78             return false;
79         }
80         if (publicURI == null) {
81             if (other.getPublic() != null) {
82                 return false;
83             }
84         } else if (!publicURI.equals(other.getPublic())) {
85             return false;
86         }
87         if (systemURI == null) {
88             if (other.getSystem() != null) {
89                 return false;
90             }
91         } else if (!systemURI.equals(other.getSystem())) {
92             return false;
93         }
94         return true;
95     }
96
97     /**
98      * Returns the sum of the hashcodes of {name,publicURI,systemURI}
99      * for whichever properties in that set is non null. This is
100      * consistent with the implementation of equals, as required by
101      * {@link java.lang.Object#hashCode() Object.hashCode}.
102      *
103      * @return an <code>int</code> value
104      */

105     public int hashCode() {
106         int hash = 0;
107         if (null != name) {
108             hash += name.hashCode();
109         }
110         if (null != publicURI) {
111             hash += publicURI.hashCode();
112         }
113         if (null != systemURI) {
114             hash += systemURI.hashCode();
115         }
116         return hash;
117     }
118
119
120     // Type metadata
121
private static TypeDesc typeDesc;
122
123     static {
124         typeDesc = new TypeDesc(Notation.class);
125         FieldDesc field;
126
127         // An attribute with a specified QName
128
field = new AttributeDesc();
129         field.setFieldName("name");
130         field.setXmlName(Constants.XSD_NCNAME);
131         typeDesc.addFieldDesc(field);
132
133         // An attribute with a default QName
134
field = new AttributeDesc();
135         field.setFieldName("public");
136         field.setXmlName(Constants.XSD_ANYURI);
137         typeDesc.addFieldDesc(field);
138
139         // An element with a specified QName
140
ElementDesc element = null;
141         element = new ElementDesc();
142         element.setFieldName("system");
143         element.setXmlName(Constants.XSD_ANYURI);
144         // per, http://www.w3.org/TR/xmlschema-1/#element-notation,
145
// "system" property can be null
146
element.setNillable(true);
147         typeDesc.addFieldDesc(field);
148     }
149
150     public static TypeDesc getTypeDesc() {
151         return typeDesc;
152     }
153 }
154
Popular Tags