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 java.beans.IntrospectionException;
21
22 import org.apache.commons.betwixt.ElementDescriptor;
23
24
25
26
27
28 public class SimpleLocalElement extends LocalElement {
29
30 private String type;
31
32 public SimpleLocalElement(String name, String type) {
33 super(name);
34 setType(type);
35 }
36
37 public SimpleLocalElement(
38 TranscriptionConfiguration configuration,
39 ElementDescriptor descriptor,
40 Schema schema)
41 throws IntrospectionException {
42 super(descriptor, schema);
43 setType(configuration.getDataTypeMapper().toXMLSchemaDataType(descriptor.getPropertyType()));
44 }
45
46 public String getType() {
47 return type;
48 }
49
50 public void setType(String string) {
51 type = string;
52 }
53
54 public int hashCode() {
55 return getName().hashCode();
56 }
57
58 public boolean equals(Object obj) {
59 boolean result = false;
60 if (obj instanceof SimpleLocalElement) {
61 SimpleLocalElement simpleLocalElement = (SimpleLocalElement) obj;
62 result =
63 isEqual(getName(), simpleLocalElement.getName()) &&
64 isEqual(getType(), simpleLocalElement.getType());
65 }
66 return result;
67 }
68
69 private boolean isEqual(String one, String two) {
70 if (one == null) {
71 return (two == null);
72 }
73
74 return one.equals(two);
75 }
76
77 public String toString() {
78 StringBuffer buffer = new StringBuffer();
79 buffer.append("<element name='");
80 buffer.append(getName());
81 buffer.append("' type='");
82 buffer.append(getType());
83 buffer.append("'/>");
84 return buffer.toString();
85 }
86 }