1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.betwixt.schema;
18
19 import java.beans.IntrospectionException;
20
21 import org.apache.commons.betwixt.ElementDescriptor;
22
23 /***
24 * @author <a href='http://jakarta.apache.org/'>Apache Commons Team</a>
25 * @version $Revision: 1.2 $
26 */
27 public class SimpleLocalElement extends LocalElement {
28
29 private String type;
30
31 public SimpleLocalElement(String name, String type) {
32 super(name);
33 setType(type);
34 }
35
36 public SimpleLocalElement(
37 TranscriptionConfiguration configuration,
38 ElementDescriptor descriptor,
39 Schema schema)
40 throws IntrospectionException {
41 super(descriptor, schema);
42 setType(configuration.getDataTypeMapper().toXMLSchemaDataType(descriptor.getPropertyType()));
43 }
44
45 public String getType() {
46 return type;
47 }
48
49 public void setType(String string) {
50 type = string;
51 }
52
53 public int hashCode() {
54 return getName().hashCode();
55 }
56
57 public boolean equals(Object obj) {
58 boolean result = false;
59 if (obj instanceof SimpleLocalElement) {
60 SimpleLocalElement simpleLocalElement = (SimpleLocalElement) obj;
61 result =
62 isEqual(getName(), simpleLocalElement.getName()) &&
63 isEqual(getType(), simpleLocalElement.getType());
64 }
65 return result;
66 }
67
68 private boolean isEqual(String one, String two) {
69 if (one == null) {
70 return (two == null);
71 }
72
73 return one.equals(two);
74 }
75
76 public String toString() {
77 StringBuffer buffer = new StringBuffer();
78 buffer.append("<element name='");
79 buffer.append(getName());
80 buffer.append("' type='");
81 buffer.append(getType());
82 buffer.append("'/>");
83 return buffer.toString();
84 }
85 }