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 type
013: *
014: *@author Chris Seguin
015: *@created July 23, 1999
016: */
017: public class TypeMetrics {
018: /*<Instance Variables>*/
019: private String packageName;
020: private String typeName;
021: private int publicMethodCount = 0;
022: private int otherMethodCount = 0;
023: private int classMethodCount = 0;
024: private int instanceVariableCount = 0;
025: private int classVariableCount = 0;
026: private int statementTotal = 0;
027: private int parameterTotal = 0;
028: private int blockDepthTotal = 0;
029: private int lineCountTotal = 0;
030:
031: /*</Instance Variables>*/
032:
033: /*<Constructor>*/
034: /**
035: * Constructor for the TypeMetrics object
036: *
037: *@param initPackage The package
038: *@param initType The type
039: */
040: public TypeMetrics(String initPackage, String initType) {
041: packageName = initPackage;
042: typeName = initType;
043: }
044:
045: /*</Constructor>*/
046:
047: /*<Getters>*/
048: /**
049: * Return the package name
050: *
051: *@return the package name
052: */
053: public String getPackageName() {
054: return packageName;
055: }
056:
057: /**
058: * Return the type name
059: *
060: *@return The type name
061: */
062: public String getTypeName() {
063: return typeName;
064: }
065:
066: /**
067: * Return the public method count
068: *
069: *@return The public method count
070: */
071: public int getPublicMethodCount() {
072: return publicMethodCount;
073: }
074:
075: /**
076: * Return the other method count
077: *
078: *@return The other method count
079: */
080: public int getOtherMethodCount() {
081: return otherMethodCount;
082: }
083:
084: /**
085: * Return the class method count
086: *
087: *@return The class method count
088: */
089: public int getClassMethodCount() {
090: return classMethodCount;
091: }
092:
093: /**
094: * Return the instance variable count
095: *
096: *@return The instance variable count
097: */
098: public int getInstanceVariableCount() {
099: return instanceVariableCount;
100: }
101:
102: /**
103: * Return the class variable count
104: *
105: *@return The class variable count
106: */
107: public int getClassVariableCount() {
108: return classVariableCount;
109: }
110:
111: /**
112: * Return the statement total
113: *
114: *@return The statement total
115: */
116: public int getStatementTotal() {
117: return statementTotal;
118: }
119:
120: /**
121: * Return the parameter total
122: *
123: *@return The parameter total
124: */
125: public int getParameterTotal() {
126: return parameterTotal;
127: }
128:
129: /**
130: * Return the block depth for use in computing system wide averages
131: *
132: *@return The block depth total
133: */
134: public int getBlockDepthTotal() {
135: return blockDepthTotal;
136: }
137:
138: /**
139: * Return the lines of code for use in computing system wide averages
140: *
141: *@return The block depth total
142: */
143: public int getLinesOfCodeTotal() {
144: return lineCountTotal;
145: }
146:
147: /**
148: * Return the statement average
149: *
150: *@return The statement average
151: */
152: public double getStatementAverage() {
153: double top = statementTotal;
154: double bottom = publicMethodCount + otherMethodCount
155: + classMethodCount;
156: return top / bottom;
157: }
158:
159: /**
160: * Return the parameter average
161: *
162: *@return The parameter average
163: */
164: public double getParameterAverage() {
165: double top = parameterTotal;
166: double bottom = publicMethodCount + otherMethodCount
167: + classMethodCount;
168: return top / bottom;
169: }
170:
171: /**
172: * Return the average block depth
173: *
174: *@return The parameter average
175: */
176: public double getBlockDepthAverage() {
177: double top = blockDepthTotal;
178: double bottom = publicMethodCount + otherMethodCount
179: + classMethodCount;
180: return top / bottom;
181: }
182:
183: /**
184: * Return the average lines of code
185: *
186: *@return The parameter average
187: */
188: public double getLinesOfCodeAverage() {
189: double top = lineCountTotal;
190: double bottom = publicMethodCount + otherMethodCount
191: + classMethodCount;
192: return top / bottom;
193: }
194:
195: /*</Getters>*/
196:
197: /*<Setters>*/
198: /**
199: * Increment the public method count
200: */
201: void incrPublicMethodCount() {
202: publicMethodCount++;
203: }
204:
205: /**
206: * Increment the other method count
207: */
208: void incrOtherMethodCount() {
209: otherMethodCount++;
210: }
211:
212: /**
213: * Increment the class method count
214: */
215: void incrClassMethodCount() {
216: classMethodCount++;
217: }
218:
219: /**
220: * Increment the instance variable count
221: */
222: void incrInstanceVariableCount() {
223: instanceVariableCount++;
224: }
225:
226: /**
227: * Increment the class variable count
228: */
229: void incrClassVariableCount() {
230: classVariableCount++;
231: }
232:
233: /**
234: * Add in a method
235: *
236: *@param methodData the method data
237: */
238: void add(MethodMetrics methodData) {
239: statementTotal += methodData.getStatementCount();
240: parameterTotal += methodData.getParameterCount();
241: blockDepthTotal += methodData.getBlockDepth();
242: lineCountTotal += methodData.getLinesOfCode();
243: }
244: /*</Setters>*/
245: }
|