mChaRM.PremChaRM
Class PreUtils

java.lang.Object
  |
  +--mChaRM.PremChaRM.PreUtils

public class PreUtils
extends java.lang.Object

This class contains lots of utilities for PremChaRM class. It contains only static fields and methods.

Author:
Valentina Cordì, Maurizio Mazza, Roberto Montagna

Field Summary
static int dbgAllocation
          Constant value for debugging.
static int dbgGraphField
          Constant value for debugging.
static int dbgGraphMethod
          Constant value for debugging.
static int dbgMethodCall
          Constant value for debugging.
static int dbgOpenClasses
          Constant value for debugging.
static int dbgPrepClasses
          Constant value for debugging.
static int dbgPrintClasses
          Constant value for debugging.
static int dbgPrintExpression
          Constant value for debugging.
static int dbgSyntax
          Constant value for debugging.
static int dbgUtils
          Constant value for debugging.
static boolean[] debugLevel
          Boolean array determining which debug levels have to be considered.
 
Constructor Summary
PreUtils()
           
 
Method Summary
static java.util.Vector array2Vector(java.lang.Object[] inputArray)
          This utility get a Vector object from an array one.
static boolean equalsParameterType(OJMethod m1, OJMethod m2)
          This method tests if two OJMethod objects have the same parameter types.
static boolean equalsParameterType(java.lang.String[] m1, java.lang.String[] m2)
          This method tests if two arrays of String have the same values.
static java.util.Vector fieldHandling(StatementList body, java.util.Vector parameters, java.util.Vector ojFields)
          This method returns all fields accessed by the given statements.
static void getCalledMethods(OJMethod method, java.util.Vector foundMethods, java.util.Vector allEnvs)
          This method returns all MethodCall expressions present in the given OJMethod object's body.
(package private) static boolean overriddenMethod(OJMethod ojMethod1, OJMethod ojMethod2)
          Check if two given OJMethod objects are overridden.
static void printDebug(java.lang.String Msg, int type, int level)
          Print on standard output the given string if the cell of debugLevel[] specified by type is true.
static void printExceptionText(java.lang.String Text, java.lang.Throwable e)
          Print on standard error the given string followed by the stack trace of the given expression.
static void setName(java.lang.String name)
          This method allow to change the name of the class instanciating PremChaRM class.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbgSyntax

public static final int dbgSyntax
Constant value for debugging. It represent the Syntax checking level of the debugging phase.

dbgOpenClasses

public static final int dbgOpenClasses
Constant value for debugging. It represent the OpenClasses level of the debugging phase.

dbgPrepClasses

public static final int dbgPrepClasses
Constant value for debugging. It represent the prepearing class level of the debugging phase.

dbgGraphMethod

public static final int dbgGraphMethod
Constant value for debugging. It represent the level of construction of the methods graph in the debugging phase.

dbgGraphField

public static final int dbgGraphField
Constant value for debugging. It represent the level of construction of the fields graph in the debugging phase.

dbgUtils

public static final int dbgUtils
Constant value for debugging. It represent the lowest level of the debugging phase.

dbgPrintClasses

public static final int dbgPrintClasses
Constant value for debugging. It represent the printing-to-file level of the debugging phase.

dbgPrintExpression

public static final int dbgPrintExpression
Constant value for debugging. It represent the expressions evalutation level of the debugging phase.

dbgAllocation

public static final int dbgAllocation
Constant value for debugging. It represent the allocation expansion level of the debugging phase.

dbgMethodCall

public static final int dbgMethodCall
Constant value for debugging. It represent the method call expansion level of the debugging phase.

debugLevel

public static final boolean[] debugLevel
Boolean array determining which debug levels have to be considered. If the value is false that level must not be present, othewise it must be. It is used by printDebug method.
Constructor Detail

PreUtils

public PreUtils()
Method Detail

setName

public static void setName(java.lang.String name)
This method allow to change the name of the class instanciating PremChaRM class. It only sets private field className to name.
Parameters:
name - the name of the class instanciating PremChaRM class.

equalsParameterType

public static boolean equalsParameterType(java.lang.String[] m1,
                                          java.lang.String[] m2)
This method tests if two arrays of String have the same values.
Parameters:
m1 - first array.
m2 - second array.
Returns:
the comparison between parameters.

equalsParameterType

public static boolean equalsParameterType(OJMethod m1,
                                          OJMethod m2)
This method tests if two OJMethod objects have the same parameter types. It returns true if methods have the same number of parameters and they have the same types.
Parameters:
m1 - first OJMethod object.
m2 - second OJMethod object.
Returns:
the comparison between methods parameters.

getCalledMethods

public static void getCalledMethods(OJMethod method,
                                    java.util.Vector foundMethods,
                                    java.util.Vector allEnvs)
This method returns all MethodCall expressions present in the given OJMethod object's body. It get all statements of the method's body and examine one by one recoursively to find every methods called by that.To do that it calls on every statement the function getCalledMethodsByExpression.
Parameters:
method - starting OJMethod object.
Returns:
a Vector of MethodCall expressions found in the method's body.

fieldHandling

public static java.util.Vector fieldHandling(StatementList body,
                                             java.util.Vector parameters,
                                             java.util.Vector ojFields)
This method returns all fields accessed by the given statements. To do that it examins every single statement (using statementHandling method) to find used fields.
Parameters:
body - starting statements to check (usually it is the body of a method).
parameters - a String Vector containing starting variables (usually these are a method's parameters).
ojFields - fields already declared (usually got with getAllFields).
Returns:
Vector of OJFields accessed by the given statements.

array2Vector

public static java.util.Vector array2Vector(java.lang.Object[] inputArray)
This utility get a Vector object from an array one.
Parameters:
inputArray - input Object array to be changed into Vector.
Returns:
Vector corresponding to given array.

overriddenMethod

static boolean overriddenMethod(OJMethod ojMethod1,
                                OJMethod ojMethod2)
Check if two given OJMethod objects are overridden. To do that it check if they have the same name and the same parameters (using equalsParameterType
Parameters:
ojMethod1 - first OJMethod object.
ojMethod2 - second OJMethod object.
Returns:
true if given methods are overridden.

printExceptionText

public static void printExceptionText(java.lang.String Text,
                                      java.lang.Throwable e)
Print on standard error the given string followed by the stack trace of the given expression.
Parameters:
Text - String to be printed.
e - Exception whose stack trace must be printed.

printDebug

public static void printDebug(java.lang.String Msg,
                              int type,
                              int level)
Print on standard output the given string if the cell of debugLevel[] specified by type is true.
Parameters:
Msg - String to be printed.
type - index of debudLevel[] rappresenting the type of print.
level - rappresent the indent of print.