1 /*
2 Bloof - visualize the evolution of your software project
3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de>
4 http://bloof.sf.net/
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for 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.,
16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 $RCSfile: MetricParameter.java,v $
19 Created on $Date: 2003/10/13 15:52:31 $
20 */
21 package net.sf.bloof.metrics;
22
23 import java.util.HashMap;
24 import java.util.Iterator;
25
26 /***
27 * Container class that encapsulates the parameters that
28 * can be applied to metrics
29 * @author Lukasz Pekacki <pekacki@users.sourceforge.net>
30 * @version $Id: MetricParameter.java,v 1.12 2003/10/13 15:52:31 pekacki Exp $
31 */
32 public class MetricParameter {
33 /***
34 * Constructs a MetricParameter object
35 * @param aDevelopers list of developers; use null if all developers should be included
36 * @param aTimeInterval interval for metric; use null if the whole timespan should be included
37 * @param aFileGroup fileGroups to include; use null if all files should be included
38 */
39 public MetricParameter(
40 DeveloperGroup aDevelopers,
41 TimeInterval aTimeInterval,
42 FileGroup aFileGroup) {
43 mTimeInterval = aTimeInterval;
44 mFileGroup = aFileGroup;
45 mDevelopers = aDevelopers;
46 }
47 /***
48 * Constructs a MetricParameter object from a HashMap of parameters. For the default
49 * Bloof filters, use the following keys: PARAM_FILE_GROUP, PARAM_DEVELOPER_GROUP, PARAM_TIME_SPAN
50 * @param aParams HashMap containing the parameters of this object
51 */
52 public MetricParameter(HashMap aParams) {
53 mTimeInterval =
54 aParams.containsKey(PARAM_TIME_SPAN)
55 ? (TimeInterval) aParams.get(PARAM_TIME_SPAN)
56 : null;
57 mFileGroup =
58 aParams.containsKey(PARAM_TIME_SPAN)
59 ? (FileGroup) aParams.get(PARAM_TIME_SPAN)
60 : null;
61 mDevelopers =
62 aParams.containsKey(PARAM_TIME_SPAN)
63 ? (DeveloperGroup) aParams.get(PARAM_TIME_SPAN)
64 : null;
65
66 }
67
68 /***
69 * Special constructor for the SQL query metric
70 * @param aSqlQuery SQL query
71 */
72 public MetricParameter(String aSqlQuery) {
73 mSqlQuery = aSqlQuery;
74 }
75
76
77 /***
78 * Add a key-value pair to the params list
79 * @param aKey key of the new pair
80 * @param aValue value of the new pair
81 */
82 public void addParams(Object aKey, Object aValue) {
83 mParams.put(aKey, aValue);
84 }
85
86 /***
87 * Returns the developers.
88 * @return DeveloperGroup
89 */
90 public DeveloperGroup getDevelopers() {
91 return mDevelopers;
92 }
93 /***
94 * Returns an Iterator over all filenames specified in this
95 * parameter
96 * @return Iterator over all filenames specified in this
97 * parameter
98 */
99 public FileGroup getFileNames() {
100 return mFileGroup;
101 }
102
103 /***
104 * Returns an iterator on the key set of generic key-value parameters
105 * @return iterator on the key set of generic key-value parameters, null if no
106 * key-value parameters are present
107 */
108 public Iterator getKeys() {
109 return mParams.keySet().iterator();
110 }
111
112 /***
113 * Returns the parameter for the specified key.
114 * @param aKey key to use.
115 * @return parameter to this key. If not found, returns null.
116 */
117 public Object getParameter(String aKey) {
118 if (mParams != null) {
119 return mParams.get(aKey);
120 } else {
121 return null;
122 }
123 }
124 /***
125 * @return SQL query
126 */
127 public String getSqlQuery() {
128 return mSqlQuery;
129 }
130 /***
131 * Returns the timeInterval.
132 * @return TimeInterval
133 */
134 public TimeInterval getTimeInterval() {
135 return mTimeInterval;
136 }
137 /***
138 * Checks if the Parameter contains a developer filter
139 * @return boolean
140 */
141 public boolean hasDeveloperFilter() {
142 return (mDevelopers != null);
143 }
144 /***
145 * Checks if the Parameter contains a file interval
146 * @return boolean
147 */
148 public boolean hasFileFilter() {
149 return (mFileGroup != null);
150 }
151
152 /***
153 * Checks if the Parameter contains a time interval
154 * @return boolean
155 */
156 public boolean hasTimeInterval() {
157 return (mTimeInterval != null);
158 }
159 /***
160 * Keys for the default filters for file, developers and time span
161 * */
162 public static final String PARAM_FILE_GROUP = "file group",
163 PARAM_DEVELOPER_GROUP = "developer group",
164 PARAM_TIME_SPAN = "time span";
165
166 private DeveloperGroup mDevelopers;
167 private FileGroup mFileGroup;
168 private HashMap mParams = new HashMap();
169 private String mSqlQuery;
170 private TimeInterval mTimeInterval;
171 }
This page was automatically generated by Maven