1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.betwixt.schema;
19
20 import org.apache.commons.betwixt.AttributeDescriptor;
21
22
23
24
25
26
27
28 public class Attribute {
29
30 private String name;
31 private String type;
32
33
34 public Attribute() {}
35
36 public Attribute(String name, String type) {
37 setName(name);
38 setType(type);
39 }
40
41 public Attribute(AttributeDescriptor attributeDescriptor) {
42 this(attributeDescriptor.getQualifiedName(),"xsd:string");
43 }
44
45
46
47
48
49
50 public String getName() {
51 return name;
52 }
53
54
55
56
57
58 public void setName(String string) {
59 name = string;
60 }
61
62
63
64
65
66 public String getType() {
67 return type;
68 }
69
70
71
72
73
74 public void setType(String string) {
75 type = string;
76 }
77
78 public int hashCode() {
79 return 0;
80 }
81
82 public boolean equals(Object obj) {
83 boolean result = false;
84 if (obj instanceof Attribute) {
85 Attribute attribute = (Attribute) obj;
86 result = isEqual(type, attribute.type) &&
87 isEqual(name, attribute.name);
88 }
89 return result;
90 }
91
92
93
94
95
96
97
98 private boolean isEqual(String one, String two) {
99 boolean result = false;
100 if (one == null) {
101 result = (two == null);
102 }
103 else
104 {
105 result = one.equals(two);
106 }
107
108 return result;
109 }
110
111 public String toString() {
112 return "<xsd:attribute name='" + name + "' type='" + type + "'/>";
113 }
114
115 }