1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.indi.objects;
20
21 import java.io.Serializable;
22 import java.util.LinkedList;
23
24
25
26
27
28
29
30 public abstract class Element extends Object<Object> implements Serializable {
31
32
33
34 private static final long serialVersionUID = 1L;
35
36
37
38
39
40 protected abstract String getType();
41
42
43
44
45 protected String value;
46
47
48
49 protected String label;
50
51
52
53 protected String name;
54
55
56
57
58
59
60
61
62
63
64
65 public Element(String name, String label, String value) {
66 super(new LinkedList<Object>());
67 this.label = label;
68 this.value = value;
69 this.name = name;
70 }
71
72
73
74
75
76
77
78
79 public String getStartTag(TransferType type) {
80 switch (type) {
81 case Def:
82 return "<def" + getType() + " name=\"" + this.name + "\" label=\""
83 + this.label + "\"> ";
84 default:
85 return "<one" + getType() + " name=\"" + this.name + "\"> ";
86 }
87 }
88
89
90
91
92
93
94
95
96 public String getEndTag(TransferType type) {
97 switch (type) {
98 case Def:
99 return "</def" + getType() + "> ";
100 default:
101 return "</one" + getType() + "> ";
102 }
103 }
104
105
106
107
108
109
110
111
112 public String getValue(TransferType type) {
113 return this.value;
114 }
115
116
117
118
119
120
121
122 public void setValue(String value) {
123 this.value = value;
124 }
125
126
127
128
129
130
131
132 public String getXML(TransferType type) {
133 return getStartTag(type) + getValue(type) + getEndTag(type);
134 }
135
136
137
138
139 public String getName() {
140 return this.name;
141 }
142
143 @Override
144 public boolean oEquals(Object o) {
145 if (o instanceof Element) {
146 Element e = (Element) o;
147 return this.name.equals(e.name) && getType().equals(e.getType());
148 } else {
149 return false;
150 }
151 }
152
153 @Override
154 public int hashCode() {
155 return this.name.hashCode();
156 };
157 }