1 16 17 package org.apache.commons.betwixt.schema; 18 19 import org.apache.commons.betwixt.AttributeDescriptor; 20 21 22 27 public class Attribute { 28 29 private String name; 30 private String type; 31 32 33 public Attribute() {} 34 35 public Attribute(String name, String type) { 36 setName(name); 37 setType(type); 38 } 39 40 public Attribute(AttributeDescriptor attributeDescriptor) { 41 this(attributeDescriptor.getQualifiedName(),"xsd:string"); 42 } 43 44 45 49 public String getName() { 50 return name; 51 } 52 53 57 public void setName(String string) { 58 name = string; 59 } 60 61 65 public String getType() { 66 return type; 67 } 68 69 73 public void setType(String string) { 74 type = string; 75 } 76 77 public int hashCode() { 78 return 0; 79 } 80 81 public boolean equals(Object obj) { 82 boolean result = false; 83 if (obj instanceof Attribute) { 84 Attribute attribute = (Attribute) obj; 85 result = isEqual(type, attribute.type) && 86 isEqual(name, attribute.name); 87 } 88 return result; 89 } 90 91 97 private boolean isEqual(String one, String two) { 98 boolean result = false; 99 if (one == null) { 100 result = (two == null); 101 } 102 else 103 { 104 result = one.equals(two); 105 } 106 107 return result; 108 } 109 110 public String toString() { 111 return "<xsd:attribute name='" + name + "' type='" + type + "'/>"; 112 } 113 114 } 115 | Popular Tags |