View Javadoc

1   /*
2    * Copyright (c) 2004 UNINETT FAS
3    *
4    * This program is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU General Public License as published by the Free
6    * Software Foundation; either version 2 of the License, or (at your option)
7    * any later version.
8    *
9    * This program is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11   * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12   * more details.
13   *
14   * You should have received a copy of the GNU General Public License along with
15   * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16   * Place - Suite 330, Boston, MA 02111-1307, USA.
17   *
18   * $Id: StatisticsData.java,v 1.3 2005/10/21 10:33:08 indal Exp $
19   */
20  package no.feide.moria.servlet;
21  import java.util.HashMap;
22  
23  /***
24   * @author Eva Indal
25   * @version $Revision: 1.3 $
26   *
27   */
28  public class StatisticsData {
29      
30      private String name;
31      private HashMap monthdata;
32      
33      //Constructor
34      public StatisticsData () {
35          name = null;
36          monthdata = new HashMap();
37      }
38      
39      public void setName(final String name) {
40          this.name = name;
41      }
42      
43      public void addMonth(final String month, final int count) {
44          Integer oldcount = (Integer) this.monthdata.get(month);
45          if (oldcount != null) {
46              int val = oldcount.intValue();
47              val += count;
48              this.monthdata.put(month, new Integer(val));
49          }
50          else {
51            this.monthdata.put(month, new Integer(count));
52          }
53      }
54          
55      public String getName() {
56          return name;
57      }
58      int getCount(final String month) {
59          final Integer val = (Integer) this.monthdata.get(month);
60          if (val != null) return val.intValue();
61          return 0;
62  
63      }
64  
65  }