001: /*
002: * Author: Chris Seguin
003: *
004: * This software has been developed under the copyleft
005: * rules of the GNU General Public License. Please
006: * consult the GNU General Public License for more
007: * details about use and distribution of this software.
008: */
009: package org.acm.seguin.metrics;
010:
011: /**
012: * Stores the metrics for a particular project
013: *
014: *@author Chris Seguin
015: *@created July 23, 1999
016: */
017: public class ProjectMetrics {
018: /*<Instance Variables>*/
019: private int publicMethodTotal = 0;
020: private int otherMethodTotal = 0;
021: private int classMethodTotal = 0;
022: private int instanceVariableTotal = 0;
023: private int classVariableTotal = 0;
024: private int classTotal = 0;
025: private int abstractClassTotal = 0;
026: private int interfaceTotal = 0;
027: private int statementTotal = 0;
028: private int parameterTotal = 0;
029:
030: /*</Instance Variables>*/
031:
032: /*<Constructor>*/
033: /**
034: * Constructor for the ProjectMetrics object
035: */
036: public ProjectMetrics() {
037: }
038:
039: /*</Constructor>*/
040:
041: /*<Getters>*/
042: /**
043: * Return the public method count
044: *
045: *@return The public method count
046: */
047: public int getPublicMethodTotal() {
048: return publicMethodTotal;
049: }
050:
051: /**
052: * Return the other method count
053: *
054: *@return The other method count
055: */
056: public int getOtherMethodTotal() {
057: return otherMethodTotal;
058: }
059:
060: /**
061: * Return the class method count
062: *
063: *@return The class method count
064: */
065: public int getClassMethodTotal() {
066: return classMethodTotal;
067: }
068:
069: /**
070: * Return the class method count
071: *
072: *@return The class method count
073: */
074: public int getMethodTotal() {
075: return publicMethodTotal + classMethodTotal + otherMethodTotal;
076: }
077:
078: /**
079: * Return the instance variable count
080: *
081: *@return The instance variable count
082: */
083: public int getInstanceVariableTotal() {
084: return instanceVariableTotal;
085: }
086:
087: /**
088: * Return the class variable count
089: *
090: *@return The class variable count
091: */
092: public int getClassVariableTotal() {
093: return classVariableTotal;
094: }
095:
096: /**
097: * Return the class count
098: *
099: *@return The class count
100: */
101: public int getClassTotal() {
102: return classTotal;
103: }
104:
105: /**
106: * Return the abstract class count
107: *
108: *@return The abstract class count
109: */
110: public int getAbstractClassTotal() {
111: return abstractClassTotal;
112: }
113:
114: /**
115: * Return the abstract class count
116: *
117: *@return The abstract class count
118: */
119: public int getInterfaceTotal() {
120: return interfaceTotal;
121: }
122:
123: /**
124: * Return the statement total
125: *
126: *@return The statement total
127: */
128: public int getStatementTotal() {
129: return statementTotal;
130: }
131:
132: /**
133: * Return the parameter total
134: *
135: *@return The parameter total
136: */
137: public int getParameterTotal() {
138: return parameterTotal;
139: }
140:
141: /**
142: * Return the statement average
143: *
144: *@return The statement average
145: */
146: public double getStatementAverage() {
147: double top = statementTotal;
148: double bottom = publicMethodTotal + otherMethodTotal
149: + classMethodTotal;
150: return top / bottom;
151: }
152:
153: /**
154: * Return the parameter average
155: *
156: *@return The parameter average
157: */
158: public double getParameterAverage() {
159: double top = parameterTotal;
160: double bottom = publicMethodTotal + otherMethodTotal
161: + classMethodTotal;
162: return top / bottom;
163: }
164:
165: /**
166: * Return the public method count
167: *
168: *@return The public method count
169: */
170: public double getPublicMethodAverage() {
171: double top = publicMethodTotal;
172: double bottom = classTotal;
173: return top / bottom;
174: }
175:
176: /**
177: * Return the other method count
178: *
179: *@return The other method count
180: */
181: public double getOtherMethodAverage() {
182: double top = otherMethodTotal;
183: double bottom = classTotal;
184: return top / bottom;
185: }
186:
187: /**
188: * Return the class method count
189: *
190: *@return The class method count
191: */
192: public double getClassMethodAverage() {
193: double top = classMethodTotal;
194: double bottom = classTotal;
195: return top / bottom;
196: }
197:
198: /**
199: * Return the instance variable count
200: *
201: *@return The instance variable count
202: */
203: public double getInstanceVariableAverage() {
204: double top = instanceVariableTotal;
205: double bottom = classTotal;
206: return top / bottom;
207: }
208:
209: /**
210: * Return the class variable count
211: *
212: *@return The class variable count
213: */
214: public double getClassVariableAverage() {
215: double top = classVariableTotal;
216: double bottom = classTotal;
217: return top / bottom;
218: }
219:
220: /**
221: * Return the abstract class count
222: *
223: *@return The abstract class count
224: */
225: public double getAbstractClassPercentage() {
226: double top = abstractClassTotal;
227: double bottom = classTotal;
228: return 100 * top / bottom;
229: }
230:
231: /**
232: * Return the abstract class count
233: *
234: *@return The abstract class count
235: */
236: public double getInterfacePercentage() {
237: double top = interfaceTotal;
238: double bottom = classTotal;
239: return 100 * top / bottom;
240: }
241:
242: /*</Getters>*/
243:
244: /*<Setters>*/
245: /**
246: * Add in a package
247: *
248: *@param packageData the package data
249: */
250: void add(PackageMetrics packageData) {
251: classTotal += packageData.getClassTotal();
252: abstractClassTotal += packageData.getAbstractClassCount();
253: interfaceTotal += packageData.getInterfaceCount();
254: publicMethodTotal += packageData.getPublicMethodTotal();
255: otherMethodTotal += packageData.getOtherMethodTotal();
256: classMethodTotal += packageData.getClassMethodTotal();
257: instanceVariableTotal += packageData.getInstanceVariableTotal();
258: classVariableTotal += packageData.getClassVariableTotal();
259: statementTotal += packageData.getStatementTotal();
260: parameterTotal += packageData.getParameterTotal();
261: }
262: /*</Setters>*/
263: }
|