View Javadoc

1   /*
2    * The contents of this file are subject to the terms 
3    * of the Common Development and Distribution License 
4    * (the "License").  You may not use this file except 
5    * in compliance with the License.
6    * 
7    * You can obtain a copy of the license at 
8    * http://www.sun.com/cddl/cddl.html. 
9    * See the License for the specific language governing 
10   * permissions and limitations under the License.
11   * 
12   * When distributing Covered Code, include this CDDL 
13   * HEADER in each file and include the License file at 
14   * license.txt.  If applicable, add the following below 
15   * this CDDL HEADER, with the fields enclosed by brackets 
16   * "[]" replaced with your own identifying information: 
17   * Portions Copyright [yyyy] [name of copyright owner]
18   * 
19   * Portions Copyright 2006 eBay, Inc.
20   */
21  
22  package com.ebay.carad.os.vitalsigns;
23  
24  import java.util.ArrayList;
25  import java.util.Collections;
26  import java.util.List;
27  
28  /***
29   * Basic implementation of IDashboardReportContainer for grouping arbitrary reports.
30   * @author Jeremy Thomerson
31   * @version $Id$
32   */
33  public class DashboardReportContainer implements Comparable, IDashboardReportContainer {
34  
35      private List mReports;
36      private int mSortOrder;
37      private String mGroupName;
38      
39      public List getReports() {
40          Collections.sort(mReports);
41          return Collections.unmodifiableList(mReports);
42      }
43  
44      public int getSortOrder() {
45          return mSortOrder;
46      }
47  
48      public String getGroupName() {
49          return mGroupName;
50      }
51  
52      public int compareTo(Object obj) {
53          IDashboardReportContainer rc = (IDashboardReportContainer) obj;
54          return getSortOrder() - rc.getSortOrder();
55      }
56  
57      /***
58       * @param groupName The groupName to set.
59       */
60      public void setGroupName(String groupName) {
61          mGroupName = groupName;
62      }
63  
64      /***
65       * @param reports The reports to set.
66       */
67      public void setReports(List reports) {
68          mReports = reports;
69      }
70      
71      public void addReport(IDashboardReport report) {
72          if (mReports == null) {
73              mReports = new ArrayList();
74          }
75          mReports.add(report);
76      }
77  
78      /***
79       * @param sortOrder The sortOrder to set.
80       */
81      public void setSortOrder(int sortOrder) {
82          mSortOrder = sortOrder;
83      }
84  
85  }