1 16 17 package org.apache.commons.betwixt.schema; 18 19 20 21 26 public class GlobalElement implements Element { 27 public static final String STRING_SIMPLE_TYPE="xsd:string"; 29 30 private String name; 31 private String type; 32 33 private GlobalComplexType complexType; 34 35 public GlobalElement() {} 36 37 public GlobalElement(String name, String type) { 38 setName(name); 39 setType(type); 40 } 41 42 public GlobalElement(String name, GlobalComplexType complexType) { 43 setName(name); 44 setComplexType(complexType); 45 } 46 47 48 49 50 54 public String getName() { 55 return name; 56 } 57 58 62 public void setName(String string) { 63 name = string; 64 } 65 66 70 public String getType() { 71 return type; 72 } 73 74 78 public void setType(String string) { 79 type = string; 80 } 81 82 83 87 public GlobalComplexType getComplexType() { 88 return complexType; 89 } 90 91 96 public void setComplexType(GlobalComplexType type) { 97 this.type = type.getName(); 98 complexType = type; 99 } 100 101 public boolean equals(Object obj) { 102 boolean result = false; 103 if (obj instanceof GlobalElement) { 104 GlobalElement element = (GlobalElement) obj; 105 result = isEqual(type, element.type) && 106 isEqual(name, element.name); 107 } 108 return result; 109 } 110 111 public int hashCode() { 112 return 0; 113 } 114 115 121 private boolean isEqual(String one, String two) { 122 boolean result = false; 123 if (one == null) { 124 result = (two == null); 125 } 126 else 127 { 128 result = one.equals(two); 129 } 130 131 return result; 132 } 133 134 public String toString() { 135 StringBuffer buffer = new StringBuffer (); 136 buffer.append("<xsd:element name='"); 137 buffer.append(name); 138 buffer.append("' type='"); 139 buffer.append(type); 140 buffer.append("'>"); 141 142 if (complexType != null) { 143 buffer.append(complexType); 144 } 145 buffer.append("</xsd:element>"); 146 return buffer.toString(); 147 } 148 149 150 } 151 | Popular Tags |