1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.fosstrak.epcis.repository.model;
22
23 import java.sql.Timestamp;
24
25 import org.fosstrak.epcis.utils.TimeParser;
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29
30
31
32
33
34 public class EventFieldExtension {
35
36 private static final Log LOG = LogFactory.getLog(EventFieldExtension.class);
37
38 private Long id;
39 private String prefix = null;
40 private String namespace = null;
41 private String localname = null;
42 private String fieldname = null;
43 private String valueColumnName = null;
44 private Integer intValue = null;
45 private Float floatValue = null;
46 private Timestamp dateValue = null;
47 private String strValue = null;
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 public EventFieldExtension(final String prefix, final String namespace, final String localname, final String value) {
64 this.localname = localname;
65 this.prefix = prefix;
66 this.namespace = namespace;
67 this.fieldname = namespace + "#" + localname;
68 LOG.debug(" resolved fieldname of extension to '" + fieldname + "'");
69 this.strValue = value;
70
71 try {
72 this.intValue = new Integer(strValue);
73 this.valueColumnName = "intValue";
74 LOG.debug(" value of extension is of type Integer.");
75 } catch (NumberFormatException e1) {
76 try {
77 this.floatValue = new Float(strValue);
78 this.valueColumnName = "floatValue";
79 LOG.info(" value of extension is of type Float.");
80 } catch (NumberFormatException e2) {
81 try {
82 this.dateValue = TimeParser.parseAsTimestamp(strValue);
83 this.valueColumnName = "dateValue";
84 LOG.info(" value of extension is of type Date.");
85 } catch (Exception e3) {
86
87 LOG.info(" value of extension is of type String.");
88 this.valueColumnName = "strValue";
89 }
90 }
91 }
92 }
93
94 public EventFieldExtension() {
95 super();
96 }
97
98 public Long getId() {
99 return id;
100 }
101
102 public void setId(Long id) {
103 this.id = id;
104 }
105
106
107
108
109 public Timestamp getDateValue() {
110 return dateValue;
111 }
112
113
114
115
116 public String getFieldname() {
117 return fieldname;
118 }
119
120
121
122
123 public Float getFloatValue() {
124 return floatValue;
125 }
126
127
128
129
130 public Integer getIntValue() {
131 return intValue;
132 }
133
134
135
136
137 public String getLocalname() {
138 return localname;
139 }
140
141
142
143
144 public String getNamespace() {
145 return namespace;
146 }
147
148
149
150
151 public String getPrefix() {
152 return prefix;
153 }
154
155
156
157
158 public String getStrValue() {
159 return strValue;
160 }
161
162
163
164
165 public String getValueColumnName() {
166 return valueColumnName;
167 }
168
169 public void setDateValue(Timestamp dateValue) {
170 this.dateValue = dateValue;
171 }
172
173 public void setFieldname(String fieldname) {
174 this.fieldname = fieldname;
175 }
176
177 public void setFloatValue(Float floatValue) {
178 this.floatValue = floatValue;
179 }
180
181 public void setIntValue(Integer intValue) {
182 this.intValue = intValue;
183 }
184
185 public void setLocalname(String localname) {
186 this.localname = localname;
187 }
188
189 public void setNamespace(String namespace) {
190 this.namespace = namespace;
191 }
192
193 public void setPrefix(String prefix) {
194 this.prefix = prefix;
195 }
196
197 public void setStrValue(String strValue) {
198 this.strValue = strValue;
199 }
200
201 public void setValueColumnName(String valueColumnName) {
202 this.valueColumnName = valueColumnName;
203 }
204
205 }