SandMark version 2.0


sandmark.statistics
Class Stats

java.lang.Object
  |
  +--sandmark.statistics.Stats

public class Stats
extends java.lang.Object

This class is a collection of StatisticsRecords. It builds these records from ClassFileCollection input. It can find a record, access it and provide statistical data about the classes it records.


Constructor Summary
Stats(ClassFileCollection aCollection)
          Constructs a new Statistics collection.
 
Method Summary
 boolean callsDynamicMethods(java.lang.String className, java.lang.String methodName)
          Returns true if specified method calls other dynamic methods, or false if it does not.
 boolean callsStaticMethods(java.lang.String className, java.lang.String methodName)
          Returns true if specified method calls other static methods, or false if it does not.
 boolean findPackage(java.lang.String packageToFind)
          Checks to see if the named package is in this collection.
 int getAvgNumberOfInstanceMethods()
           
 int getAvgNumberOfInstanceVariables()
           
 java.util.List getByteCode()
           
 java.util.List getByteCode(java.lang.String className, java.lang.String methodName)
          Returns the bytecode of a specified method.
 java.util.List getByteCodeByClassName(java.lang.String className)
           
 java.util.List getByteCodeByPackage(java.lang.String packageName)
           
 java.util.Hashtable getByteCodeUsage(java.lang.String className, java.lang.String methodName)
           
 int getClassHierarchyLevel(java.lang.String className)
           
 java.lang.String getClassNameAt(int index)
          Retruns the classname at the specified index
 java.util.List getListOfClassesByPackageName(java.lang.String packageName)
          Returns a list of all of the classNames are in the specified package.
 java.lang.String getMethodByteCodeUsage(java.lang.String className, java.lang.String methodName)
           
 java.lang.String[] getMethodNames(java.lang.String className)
          Retruns the names of all of the methods in the class specified
 int getMethodSizeInBytes(java.lang.String className, java.lang.String methodName)
          Retruns the size of the method in bytes, or -1 if the class or method does not exist
 java.util.List getNonStaticFields(java.lang.String className)
          Returns a List of all the Non-Static fields in the specified class.
 int getNumberOfApiCalls(java.lang.String className, java.lang.String methodName)
           
 int getNumberOfClassMethods(java.lang.String className)
           
 int getNumberOfInstanceMethods(java.lang.String className)
           
 int getNumberOfInstanceVariables(java.lang.String className)
           
 int getNumberOfMessageSends(java.lang.String className, java.lang.String methodName)
           
 int getNumberOfMethodParams(java.lang.String className, java.lang.String methodName)
           
 int getNumberOfPublicMethods(java.lang.String className)
           
 int getNumberOfStaticFields(java.lang.String className)
          Returns the number of fields in the specified class which are static, or -1 if the class does not exist
 int getNumberOfStatmentsInMethod(java.lang.String className, java.lang.String methodName)
          new stat implementation starts here ....
 int getNumClasses()
          Returns the number of classes in this collection
 int getNumClassesInPackage(java.lang.String packageName)
          Returns the number of classes in the specified package.
 int getNumFieldsNonBasicTypes(java.lang.String className)
          Returns the number of fields that are not basic in the specified class, or -1 if the class does not exist
 int getNumMethods(java.lang.String className)
          Returns the number of the method in specified class, or -1 if class does not exist.
 int getNumNonStaticFields(java.lang.String className)
           
 int getNumNonStaticFieldsByType(java.lang.String className, java.lang.String type)
          Returns the number of fields, by type in the specified class which are non-static, or -1 if the class does not exist
 int getNumPackages()
          Returns the number of packages in this collection
 java.lang.String getPackageNameAt(int index)
          Given a specific index, this method returns the packageName at that index
 java.util.List getPackageNames()
          Returns a list of all of the packages in this collection, discounting duplicates.
 boolean hasBackwardBranches(java.lang.String className, java.lang.String methodName)
          Returns true if specified method uses backward branches, or false if it does not.
 boolean hasForwardBranches(java.lang.String className, java.lang.String methodName)
          Returns true if specified method uses forward branches, or false if it does not.
static void main(java.lang.String[] argv)
           
 boolean throwsCatchesExceptions(java.lang.String className, java.lang.String methodName)
          Returns true if specified method throws or catches exceptions, or false if it does not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stats

public Stats(ClassFileCollection aCollection)
Constructs a new Statistics collection.

Parameters:
aCollection - The ClassFileCollection which contains the classes to analyze
Method Detail

getByteCode

public java.util.List getByteCode()

getByteCodeByPackage

public java.util.List getByteCodeByPackage(java.lang.String packageName)

getNumMethods

public int getNumMethods(java.lang.String className)
Returns the number of the method in specified class, or -1 if class does not exist.

Parameters:
className - the name of the class
Returns:
The number of methods in the class, or -1 if the class does not exist

getMethodNames

public java.lang.String[] getMethodNames(java.lang.String className)
Retruns the names of all of the methods in the class specified

Parameters:
className - the name of the class
Returns:
String array representing all of the method names in the class specified

getClassNameAt

public java.lang.String getClassNameAt(int index)
Retruns the classname at the specified index

Parameters:
index - the index at which to get the classname
Returns:
the name of the class at index

getNumClasses

public int getNumClasses()
Returns the number of classes in this collection

Returns:
the number of classes in this collection

getPackageNameAt

public java.lang.String getPackageNameAt(int index)
Given a specific index, this method returns the packageName at that index

Parameters:
index - the index at which to get the packageName
Returns:
the name of the package at index

getNumPackages

public int getNumPackages()
Returns the number of packages in this collection

Returns:
the number of packages in this collection

getListOfClassesByPackageName

public java.util.List getListOfClassesByPackageName(java.lang.String packageName)
Returns a list of all of the classNames are in the specified package.

Parameters:
packageName - the name of the package from which to get classNames.
Returns:
a list of all of the classNames are in the specified package.

getNumClassesInPackage

public int getNumClassesInPackage(java.lang.String packageName)
Returns the number of classes in the specified package.

Parameters:
packageName - the name of the package to investigate.
Returns:
the number of classes in the specified package.

getPackageNames

public java.util.List getPackageNames()
Returns a list of all of the packages in this collection, discounting duplicates.

Returns:
a list of all of the packages in this collection.

findPackage

public boolean findPackage(java.lang.String packageToFind)
Checks to see if the named package is in this collection.

Parameters:
packageToFind - the name of the package to look for in this collection.
Returns:
true if package exists in this collection, false if it does not.

getByteCodeByClassName

public java.util.List getByteCodeByClassName(java.lang.String className)

getByteCode

public java.util.List getByteCode(java.lang.String className,
                                  java.lang.String methodName)
Returns the bytecode of a specified method.

Parameters:
className - the name of the class.
methodName - the name of the method from which to get the bytecode.
Returns:
the List representation of the bytecode.

getMethodByteCodeUsage

public java.lang.String getMethodByteCodeUsage(java.lang.String className,
                                               java.lang.String methodName)

getByteCodeUsage

public java.util.Hashtable getByteCodeUsage(java.lang.String className,
                                            java.lang.String methodName)

getMethodSizeInBytes

public int getMethodSizeInBytes(java.lang.String className,
                                java.lang.String methodName)
Retruns the size of the method in bytes, or -1 if the class or method does not exist

Parameters:
className - the name of the class
methodName - the name of the method from which to get the size.
Returns:
the number of bytes in the method, or -1 if the class or method does not exist

throwsCatchesExceptions

public boolean throwsCatchesExceptions(java.lang.String className,
                                       java.lang.String methodName)
Returns true if specified method throws or catches exceptions, or false if it does not.

Parameters:
className - the name of the class
methodName - the name of the method to investigate
Returns:
true if specified method throws or catches exceptions, or false if it does not.

getNumNonStaticFields

public int getNumNonStaticFields(java.lang.String className)

getNumberOfStaticFields

public int getNumberOfStaticFields(java.lang.String className)
Returns the number of fields in the specified class which are static, or -1 if the class does not exist

Parameters:
className - the name of the class
Returns:
the number of fields in the specified class which are static, or -1 if the class does not exist

getNumNonStaticFieldsByType

public int getNumNonStaticFieldsByType(java.lang.String className,
                                       java.lang.String type)
Returns the number of fields, by type in the specified class which are non-static, or -1 if the class does not exist

Parameters:
className - the name of the class
type - the type to count.
Returns:
the number of fields, by type in the specified class which are non-static, or -1 if the class does not exist

getNumFieldsNonBasicTypes

public int getNumFieldsNonBasicTypes(java.lang.String className)
Returns the number of fields that are not basic in the specified class, or -1 if the class does not exist

Parameters:
className - the name of the class
Returns:
the number of fields that are not basic in the specified class, or -1 if the class does not exist

hasForwardBranches

public boolean hasForwardBranches(java.lang.String className,
                                  java.lang.String methodName)
Returns true if specified method uses forward branches, or false if it does not.

Parameters:
className - the name of the class
methodName - the name of the method to investigate
Returns:
true if specified method uses forward branches, or false if it does not.

hasBackwardBranches

public boolean hasBackwardBranches(java.lang.String className,
                                   java.lang.String methodName)
Returns true if specified method uses backward branches, or false if it does not.

Parameters:
className - the name of the class
methodName - the name of the method to investigate
Returns:
true if specified method uses backward branches, or false if it does not.

getNonStaticFields

public java.util.List getNonStaticFields(java.lang.String className)
Returns a List of all the Non-Static fields in the specified class.

Parameters:
className - the name of the class from which to retrieve the Non-static field types
Returns:
a List representation of all non-static field types in the specified class

callsStaticMethods

public boolean callsStaticMethods(java.lang.String className,
                                  java.lang.String methodName)
Returns true if specified method calls other static methods, or false if it does not.

Parameters:
className - the name of the class
methodName - the name of the method to investigate
Returns:
true if specified method calls other static methods, or false if it does not.

callsDynamicMethods

public boolean callsDynamicMethods(java.lang.String className,
                                   java.lang.String methodName)
Returns true if specified method calls other dynamic methods, or false if it does not.

Parameters:
className - the name of the class
methodName - the name of the method to investigate
Returns:
true if specified method calls other dynamic methods, or false if it does not.

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
java.lang.Exception

getNumberOfStatmentsInMethod

public int getNumberOfStatmentsInMethod(java.lang.String className,
                                        java.lang.String methodName)
new stat implementation starts here .... uses new 'StatisticsRecord' implementation ...


getNumberOfMessageSends

public int getNumberOfMessageSends(java.lang.String className,
                                   java.lang.String methodName)

getNumberOfPublicMethods

public int getNumberOfPublicMethods(java.lang.String className)

getNumberOfInstanceMethods

public int getNumberOfInstanceMethods(java.lang.String className)

getAvgNumberOfInstanceMethods

public int getAvgNumberOfInstanceMethods()

getNumberOfInstanceVariables

public int getNumberOfInstanceVariables(java.lang.String className)

getAvgNumberOfInstanceVariables

public int getAvgNumberOfInstanceVariables()

getNumberOfClassMethods

public int getNumberOfClassMethods(java.lang.String className)

getNumberOfApiCalls

public int getNumberOfApiCalls(java.lang.String className,
                               java.lang.String methodName)

getNumberOfMethodParams

public int getNumberOfMethodParams(java.lang.String className,
                                   java.lang.String methodName)

getClassHierarchyLevel

public int getClassHierarchyLevel(java.lang.String className)

SandMark version 2.0

Mon Jun 17 12:30:47 MST 2002