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