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: import org.acm.seguin.summary.*;
012: import org.acm.seguin.util.TextFormatter;
013: import java.util.Iterator;
014:
015: /**
016: * Gathers metrics data
017: *
018: *@author Chris Seguin
019: *@created July 1, 1999
020: */
021: public abstract class MetricsReport {
022: /**
023: * Make a final report on totals
024: *
025: *@param projectData Description of Parameter
026: */
027: public void finalReport(ProjectMetrics projectData) {
028: reportAverageStatements(projectData);
029: reportAveragePublicMethods(projectData);
030: reportAverageOtherMethods(projectData);
031: reportAverageClassMethods(projectData);
032: reportAverageInstanceVariables(projectData);
033: reportAverageClassVariables(projectData);
034: reportAbstractClasses(projectData);
035: reportInterfaces(projectData);
036: reportAverageParameters(projectData);
037: }
038:
039: /**
040: * Method report shows all the metrics associated with a particular type.
041: *
042: *@param typeData the metrics for a particular type
043: */
044: public void typeReport(TypeMetrics typeData) {
045: reportPublicMethods(typeData.getPackageName(), typeData
046: .getTypeName(), typeData.getPublicMethodCount());
047: reportOtherMethods(typeData.getPackageName(), typeData
048: .getTypeName(), typeData.getOtherMethodCount());
049: reportClassMethods(typeData.getPackageName(), typeData
050: .getTypeName(), typeData.getClassMethodCount());
051: reportInstanceVariables(typeData.getPackageName(), typeData
052: .getTypeName(), typeData.getInstanceVariableCount());
053: reportClassVariables(typeData.getPackageName(), typeData
054: .getTypeName(), typeData.getClassVariableCount());
055: }
056:
057: /**
058: * Method report shows all the metrics associated with a particular method.
059: *
060: *@param methodData the metrics associated with a particular method
061: */
062: public void methodReport(MethodMetrics methodData) {
063: reportStatement(methodData.getPackageName(), methodData
064: .getTypeName(), methodData.getMethodName(), methodData
065: .getStatementCount());
066: reportParameters(methodData.getPackageName(), methodData
067: .getTypeName(), methodData.getMethodName(), methodData
068: .getParameterCount());
069: reportLinesOfCode(methodData.getPackageName(), methodData
070: .getTypeName(), methodData.getMethodName(), methodData
071: .getLinesOfCode());
072: reportBlockDepth(methodData.getPackageName(), methodData
073: .getTypeName(), methodData.getMethodName(), methodData
074: .getBlockDepth());
075: }
076:
077: /**
078: * Reports on the number of statements
079: *
080: *@param pack the name of the package
081: *@param type the name of the class or interface
082: *@param name the name of the method
083: *@param count the number of statements
084: */
085: protected abstract void reportStatement(String pack, String type,
086: String name, int count);
087:
088: /**
089: * Reports on the number of parameters
090: *
091: *@param pack the name of the package
092: *@param type the name of the class or interface
093: *@param name the name of the method
094: *@param count the number of parameters
095: */
096: protected abstract void reportParameters(String pack, String type,
097: String name, int count);
098:
099: /**
100: * Reports on the number of lines of code
101: *
102: *@param pack the name of the package
103: *@param type the name of the class or interface
104: *@param name the name of the method
105: *@param count the number of parameters
106: */
107: protected abstract void reportLinesOfCode(String pack, String type,
108: String name, int count);
109:
110: /**
111: * Reports on the block depth of code
112: *
113: *@param pack the name of the package
114: *@param type the name of the class or interface
115: *@param name the name of the method
116: *@param count the number of parameters
117: */
118: protected abstract void reportBlockDepth(String pack, String type,
119: String name, int count);
120:
121: /**
122: * Reports on the average number of statements
123: *
124: *@param projectData Description of Parameter
125: */
126: protected abstract void reportAverageStatements(
127: ProjectMetrics projectData);
128:
129: /**
130: * Reports on the average number of parameters
131: *
132: *@param projectData Description of Parameter
133: */
134: protected abstract void reportAverageParameters(
135: ProjectMetrics projectData);
136:
137: /**
138: * Reports on the number of public methods
139: *
140: *@param pack the name of the package
141: *@param type the name of the class or interface
142: *@param count the number of public methods
143: */
144: protected abstract void reportPublicMethods(String pack,
145: String type, int count);
146:
147: /**
148: * Reports on the number of other methods
149: *
150: *@param pack the name of the package
151: *@param type the name of the class or interface
152: *@param count the number of other methods
153: */
154: protected abstract void reportOtherMethods(String pack,
155: String type, int count);
156:
157: /**
158: * Reports on the number of class methods
159: *
160: *@param pack the name of the package
161: *@param type the name of the class or interface
162: *@param count the number of class methods
163: */
164: protected abstract void reportClassMethods(String pack,
165: String type, int count);
166:
167: /**
168: * Reports on the number of instance variables
169: *
170: *@param pack the name of the package
171: *@param type the name of the class or interface
172: *@param count the number of instance variables
173: */
174: protected abstract void reportInstanceVariables(String pack,
175: String type, int count);
176:
177: /**
178: * Reports on the number of class variables
179: *
180: *@param pack the name of the package
181: *@param type the name of the class or interface
182: *@param count the number of class variables
183: */
184: protected abstract void reportClassVariables(String pack,
185: String type, int count);
186:
187: /**
188: * Reports on the number of abstract classes
189: *
190: *@param projectData Description of Parameter
191: */
192: protected abstract void reportAbstractClasses(
193: ProjectMetrics projectData);
194:
195: /**
196: * Reports on the number of interfaces
197: *
198: *@param projectData Description of Parameter
199: */
200: protected abstract void reportInterfaces(ProjectMetrics projectData);
201:
202: /**
203: * Reports on the number of classes
204: *
205: *@param projectData Description of Parameter
206: */
207: protected abstract void reportClasses(ProjectMetrics projectData);
208:
209: /**
210: * Reports on the average number of public methods
211: *
212: *@param projectData Description of Parameter
213: */
214: protected abstract void reportAveragePublicMethods(
215: ProjectMetrics projectData);
216:
217: /**
218: * Reports on the average number of other methods
219: *
220: *@param projectData Description of Parameter
221: */
222: protected abstract void reportAverageOtherMethods(
223: ProjectMetrics projectData);
224:
225: /**
226: * Reports on the average number of class methods
227: *
228: *@param projectData Description of Parameter
229: */
230: protected abstract void reportAverageClassMethods(
231: ProjectMetrics projectData);
232:
233: /**
234: * Reports on the average number of instance variables
235: *
236: *@param projectData Description of Parameter
237: */
238: protected abstract void reportAverageInstanceVariables(
239: ProjectMetrics projectData);
240:
241: /**
242: * Reports on the average number of class variables
243: *
244: *@param projectData Description of Parameter
245: */
246: protected abstract void reportAverageClassVariables(
247: ProjectMetrics projectData);
248: }
|