View Javadoc

1   /*
2    * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
3    * 
4    * Based in London, we are world leaders in the design and development 
5    * of bespoke applications for the securities financing markets.
6    * 
7    * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
8    *           ___  _     _           _   _          _
9    *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
10   *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
11   *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
12   *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
13   *                   |__/
14   *
15   *                     www.ObjectLab.co.uk
16   *
17   * $Id: TM3Bean.java 75 2006-10-24 23:00:51Z benoitx $
18   * 
19   * Copyright 2006 the original author or authors.
20   *
21   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
22   * use this file except in compliance with the License. You may obtain a copy of
23   * the License at
24   *
25   * http://www.apache.org/licenses/LICENSE-2.0
26   *
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30   * License for the specific language governing permissions and limitations under
31   * the License.
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  *                 ObjectLab is supporing JTreeMap
126  * 
127  * Based in London, we are world leaders in the design and development 
128  * of bespoke applications for the securities financing markets.
129  * 
130  * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
131  *           ___  _     _           _   _          _
132  *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
133  *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
134  *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
135  *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
136  *                   |__/
137  *
138  *                     www.ObjectLab.co.uk
139  */