View Javadoc

1   /*
2    * Copyright 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.commons.betwixt.schema;
18  
19  /***
20   * Models a simpleType tag in an XML schema.
21   * A simple type is an element that cannot have element content
22   * and which has no attributes.
23   * 
24   * @author <a href='http://jakarta.apache.org/'>Apache Commons Team</a>
25   * @version $Revision: 1.2 $
26   */
27  public class SimpleType {
28  	private String name;
29  	
30      /***
31       * Gets the name
32       * @return
33       */
34      public String getName() {
35          return name;
36      }
37  
38      /***
39       * Sets the name
40       * @param string
41       */
42      public void setName(String name) {
43          this.name = name;
44      }
45  
46      public boolean equals(Object obj) {
47            boolean result = false;
48            if (obj instanceof SimpleType) {
49                SimpleType simpleType = (SimpleType) obj;
50                result = isEqual(name, simpleType.name);           
51            }
52            return result;
53        }
54  
55      public int hashCode() {
56          return 0;
57      }
58  
59  
60        /***
61         * Null safe equals method
62         * @param one
63         * @param two
64         * @return
65         */
66        private boolean isEqual(String one, String two) {
67            boolean result = false;
68            if (one == null) {
69                result = (two == null); 
70            }
71            else
72            {
73                result = one.equals(two);
74            }
75          
76            return result;
77        }
78        
79        public String toString() {
80            return "<xsd:simpleType name='" + name +  "'/>";
81        }
82  }