1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 package net.sf.jtreemap.ktreemap.example;
34
35 import java.text.SimpleDateFormat;
36 import java.util.ArrayList;
37 import java.util.HashMap;
38 import java.util.TreeSet;
39
40 /**
41 * Bean that contains the values of a line of a TM3 file
42 */
43 public class TM3Bean {
44 /**
45 * label "DATE" to identify Date in TM3 data file
46 */
47 public static final String DATE = "DATE";
48 /**
49 * label "FLOAT" to identify float in TM3 data file
50 */
51 public static final String FLOAT = "FLOAT";
52 /**
53 * label "INTEGER" to identify int in TM3 data file
54 */
55 public static final String INTEGER = "INTEGER";
56 /**
57 * label "STRING" to identify String in TM3 data file
58 */
59 public static final String STRING = "STRING";
60 /**
61 * The default date format for TM3 file : MM/dd/yyyy
62 */
63 public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
64 "MM/dd/yyyy");
65
66 /**
67 * list containing the field names of the TM3 file
68 */
69 public static ArrayList<String> fieldNames = new ArrayList<String>();
70 /**
71 * list containing the field type of the TM3 file
72 */
73 public static ArrayList<String> fieldTypes = new ArrayList<String>();
74
75 private HashMap<String, Object> values = new HashMap<String, Object>();
76 private String label;
77
78 /**
79 * @return the number fields (ie INTEGER and FLOAT)
80 */
81 public static String[] getNumberFields() {
82 TreeSet<String> result = new TreeSet<String>();
83 for (int i = 0; i < fieldNames.size(); i++) {
84 String type = fieldTypes.get(i);
85 if (INTEGER.equals(type) || FLOAT.equals(type)) {
86 result.add(fieldNames.get(i));
87 }
88 }
89 return result.toArray(new String[1]);
90 }
91
92 /**
93 * set the value of the field name
94 * @param fieldName field name
95 * @param value value to set
96 */
97 public void setValue(String fieldName, Object value) {
98 values.put(fieldName, value);
99 }
100
101 /**
102 * get the value of the field
103 * @param fieldName field name
104 * @return the value of the field
105 */
106 public Object getValue(String fieldName) {
107 return values.get(fieldName);
108 }
109
110 /**
111 * @return the label
112 */
113 public String getLabel() {
114 return label;
115 }
116
117 /**
118 * @param label the label to set
119 */
120 public void setLabel(String label) {
121 this.label = label;
122 }
123 }
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139