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.util.TextFormatter;
012:
013: /**
014: * Reports metrics in a text format
015: *
016: *@author Chris Seguin
017: *@created July 1, 1999
018: */
019: public class TextReport extends MetricsReport {
020: // Instance Variables
021: private TextFormatter format;
022:
023: /**
024: * Constructor for the TextReport object
025: */
026: public TextReport() {
027: format = new TextFormatter();
028: }
029:
030: /**
031: * Reports on the number of statements
032: *
033: *@param pack the name of the package
034: *@param type the name of the class or interface
035: *@param name the name of the method
036: *@param count the number of statements
037: */
038: protected void reportStatement(String pack, String type,
039: String name, int count) {
040: System.out.println("[000] "
041: + format.rightJustifyNumber(count, 10)
042: + " statements in " + pack + " . " + type + " . "
043: + name);
044: }
045:
046: /**
047: * Reports on the number of parameters
048: *
049: *@param pack the name of the package
050: *@param type the name of the class or interface
051: *@param name the name of the method
052: *@param count the number of parameters
053: */
054: protected void reportParameters(String pack, String type,
055: String name, int count) {
056: System.out.println("[008] "
057: + format.rightJustifyNumber(count, 10)
058: + " parameters in " + pack + " . " + type + " . "
059: + name);
060: }
061:
062: /**
063: * Reports on the number of lines of code
064: *
065: *@param pack the name of the package
066: *@param type the name of the class or interface
067: *@param name the name of the method
068: *@param count the number of lines of code
069: */
070: protected void reportLinesOfCode(String pack, String type,
071: String name, int count) {
072: System.out.println("[010] "
073: + format.rightJustifyNumber(count, 10)
074: + " lines of code in " + pack + " . " + type + " . "
075: + name);
076: }
077:
078: /**
079: * Reports on the block depth of code
080: *
081: *@param pack the name of the package
082: *@param type the name of the class or interface
083: *@param name the name of the method
084: *@param count the number of blocks deep
085: */
086: protected void reportBlockDepth(String pack, String type,
087: String name, int count) {
088: System.out.println("[011] "
089: + format.rightJustifyNumber(count, 10)
090: + " block depth in " + pack + " . " + type + " . "
091: + name);
092: }
093:
094: /**
095: * Reports on the number of public methods
096: *
097: *@param pack the name of the package
098: *@param type the name of the class or interface
099: *@param count the number of public methods
100: */
101: protected void reportPublicMethods(String pack, String type,
102: int count) {
103: System.out.println("[001] "
104: + format.rightJustifyNumber(count, 10)
105: + " public methods in " + pack + " . " + type);
106: }
107:
108: /**
109: * Reports on the number of other methods
110: *
111: *@param pack the name of the package
112: *@param type the name of the class or interface
113: *@param count the number of other methods
114: */
115: protected void reportOtherMethods(String pack, String type,
116: int count) {
117: System.out.println("[002] "
118: + format.rightJustifyNumber(count, 10)
119: + " non public methods in " + pack + " . " + type);
120: }
121:
122: /**
123: * Reports on the number of class methods
124: *
125: *@param pack the name of the package
126: *@param type the name of the class or interface
127: *@param count the number of class methods
128: */
129: protected void reportClassMethods(String pack, String type,
130: int count) {
131: System.out.println("[003] "
132: + format.rightJustifyNumber(count, 10)
133: + " static methods in " + pack + " . " + type);
134: }
135:
136: /**
137: * Reports on the number of instance variables
138: *
139: *@param pack the name of the package
140: *@param type the name of the class or interface
141: *@param count the number of instance variables
142: */
143: protected void reportInstanceVariables(String pack, String type,
144: int count) {
145: System.out.println("[004] "
146: + format.rightJustifyNumber(count, 10)
147: + " instance variables in " + pack + " . " + type);
148: }
149:
150: /**
151: * Reports on the number of class variables
152: *
153: *@param pack the name of the package
154: *@param type the name of the class or interface
155: *@param count the number of class variables
156: */
157: protected void reportClassVariables(String pack, String type,
158: int count) {
159: System.out.println("[005] "
160: + format.rightJustifyNumber(count, 10)
161: + " class variables in " + pack + " . " + type);
162: }
163:
164: /**
165: * Reports on the number of abstract classes
166: *
167: *@param projectData Description of Parameter
168: */
169: protected void reportAbstractClasses(ProjectMetrics projectData) {
170: // Abstract Classes
171: double top = projectData.getAbstractClassTotal();
172: double bottom = projectData.getClassTotal();
173: System.out.println("[006] "
174: + projectData.getAbstractClassTotal()
175: + " total abstract classes in "
176: + projectData.getClassTotal() + " classes.");
177: System.out.println("[006] " + "Percentage: "
178: + (100 * top / bottom) + "%");
179: }
180:
181: /**
182: * Reports on the number of interfaces
183: *
184: *@param projectData Description of Parameter
185: */
186: protected void reportInterfaces(ProjectMetrics projectData) {
187: // Interfaces
188: double top = projectData.getInterfaceTotal();
189: double bottom = projectData.getClassTotal();
190: System.out.println("[007] " + projectData.getInterfaceTotal()
191: + " total interfaces in " + projectData.getClassTotal()
192: + " classes.");
193: System.out.println("[007] " + "Percentage: "
194: + (100 * top / bottom) + "%");
195: }
196:
197: /**
198: * Reports on the number of classes
199: *
200: *@param projectData Description of Parameter
201: */
202: protected void reportClasses(ProjectMetrics projectData) {
203: }
204:
205: /**
206: * Reports on the average number of statements
207: *
208: *@param projectData Description of Parameter
209: */
210: protected void reportAverageStatements(ProjectMetrics projectData) {
211: // Public Methods
212: double top = projectData.getStatementTotal();
213: double bottom = projectData.getMethodTotal();
214: System.out.println("[000] " + projectData.getStatementTotal()
215: + " total number of statements in "
216: + projectData.getMethodTotal() + " methods.");
217: System.out.println("[000] " + "Average: " + (top / bottom));
218: }
219:
220: /**
221: * Reports on the average number of parameters
222: *
223: *@param projectData Description of Parameter
224: */
225: protected void reportAverageParameters(ProjectMetrics projectData) {
226: // Public Methods
227: double top = projectData.getParameterTotal();
228: double bottom = projectData.getMethodTotal();
229: System.out.println("[008] " + projectData.getParameterTotal()
230: + " total number of parameters in "
231: + projectData.getMethodTotal() + " methods.");
232: System.out.println("[008] " + "Average: " + (top / bottom));
233: }
234:
235: /**
236: * Reports on the average number of public methods
237: *
238: *@param projectData Description of Parameter
239: */
240: protected void reportAveragePublicMethods(ProjectMetrics projectData) {
241: // Public Methods
242: double top = projectData.getPublicMethodTotal();
243: double bottom = projectData.getClassTotal();
244: System.out.println("[001] "
245: + projectData.getPublicMethodTotal()
246: + " total public methods in "
247: + projectData.getClassTotal() + " classes.");
248: System.out.println("[001] " + "Average: " + (top / bottom));
249: }
250:
251: /**
252: * Reports on the average number of other methods
253: *
254: *@param projectData Description of Parameter
255: */
256: protected void reportAverageOtherMethods(ProjectMetrics projectData) {
257: // Other Methods
258: double top = projectData.getOtherMethodTotal();
259: double bottom = projectData.getClassTotal();
260: System.out.println("[002] " + projectData.getOtherMethodTotal()
261: + " total other methods in "
262: + projectData.getClassTotal() + " classes.");
263: System.out.println("[002] " + "Average: " + (top / bottom));
264: }
265:
266: /**
267: * Reports on the average number of class methods
268: *
269: *@param projectData Description of Parameter
270: */
271: protected void reportAverageClassMethods(ProjectMetrics projectData) {
272: // Class Methods
273: double top = projectData.getClassMethodTotal();
274: double bottom = projectData.getClassTotal();
275: System.out.println("[003] " + projectData.getClassMethodTotal()
276: + " total class methods in "
277: + projectData.getClassTotal() + " classes.");
278: System.out.println("[003] " + "Average: " + (top / bottom));
279: }
280:
281: /**
282: * Reports on the average number of instance variables
283: *
284: *@param projectData Description of Parameter
285: */
286: protected void reportAverageInstanceVariables(
287: ProjectMetrics projectData) {
288: // Instance Variables
289: double top = projectData.getInstanceVariableTotal();
290: double bottom = projectData.getClassTotal();
291: System.out.println("[004] "
292: + projectData.getInstanceVariableTotal()
293: + " total instance variables in "
294: + projectData.getClassTotal() + " classes.");
295: System.out.println("[004] " + "Average: " + (top / bottom));
296: }
297:
298: /**
299: * Reports on the average number of class variables
300: *
301: *@param projectData Description of Parameter
302: */
303: protected void reportAverageClassVariables(
304: ProjectMetrics projectData) {
305: // Class Variables
306: double top = projectData.getClassVariableTotal();
307: double bottom = projectData.getClassTotal();
308: System.out.println("[005] "
309: + projectData.getClassVariableTotal()
310: + " total class variables in "
311: + projectData.getClassTotal() + " classes.");
312: System.out.println("[005] " + "Average: " + (top / bottom));
313: }
314: }
|