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