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