PremChaRM
Class PreGraph

java.lang.Object
  |
  +--PremChaRM.PreGraph

public class PreGraph
extends java.lang.Object

This class representing the structure of fields and methods used to resolve the problem of sharing out. It contains methods to insert methods/fields and to find multi-refered fields.

Author:
Valentina Cordì (1996s081@educ.disi.unige.it), Maurizio Mazza (1996s065@educ.disi.unige.it), Roberto Montagna (1996s063@educ.disi.unige.it)

Field Summary
private  java.util.Vector bUsedFields
          This field contains, for each field, the info about which class use it.
private  java.util.Vector bUsedMethods
          This field contains, for each method, the info about which class invoke it.
private  java.util.Vector ojFields
          This field contains all fields of the class.
private  java.util.Vector ojMethods
          This field contains all methods of the class.
 
Constructor Summary
PreGraph()
           
 
Method Summary
 java.util.Vector DangerousFields()
          This method checks if fields are dangerous, in other words it control if a fields is used by more than one class.
 OJField fieldAt(int index)
          This method return the OJField object specified by index.
 int[] fieldUsedBy(int index)
          This method return an array that rapresent in which classes the field is used.
 boolean fieldUsedBy(int index, int className)
          This method check if a field is used in a class.
 void insertFields(OJField Fields, int[] classesName)
          Put a field in the graph.
 boolean insertMethod(OJMethod Method, int className)
          Put a method in the graph.
 OJMethod methodAt(int index)
          This method return OJMethod specified by given index.
 int[] methodUsedBy(int index)
          This method return an array that rapresent in which classes a method is called.
 boolean methodUsedBy(int index, int className)
          This method check if a method is used by a class.
 int numberOfFields()
          This method return the number of fields stored.
 int numberOfMethods()
          This method return the number of methods stored.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

ojMethods

private java.util.Vector ojMethods
This field contains all methods of the class. It can be filled usig insertMethod method.

bUsedMethods

private java.util.Vector bUsedMethods
This field contains, for each method, the info about which class invoke it. It's a Vector of boolean array of three elements. Each position of the array indicates:

ojFields

private java.util.Vector ojFields
This field contains all fields of the class. It can be filled usig insertFields method.

bUsedFields

private java.util.Vector bUsedFields
This field contains, for each field, the info about which class use it. It's a Vector of boolean array that means:
Constructor Detail

PreGraph

public PreGraph()
Method Detail

numberOfMethods

public int numberOfMethods()
This method return the number of methods stored.
Returns:
size of Vector ojMethods.

methodAt

public OJMethod methodAt(int index)
This method return OJMethod specified by given index.
Parameters:
index - index of element to return
Throws:
ArrayIndexOutOfBoundsException - thrown when the index reified doesn't exist.

methodUsedBy

public boolean methodUsedBy(int index,
                            int className)
This method check if a method is used by a class.
Parameters:
index - index of method to be checked.
className - a number that representing name of class to check if method is used in.
Returns:
true if method at specified index is used by specified class.
Throws:
ArrayIndexOutOfBoundsException - thrown when the index reified doesn't exist in bUsedMethods.

methodUsedBy

public int[] methodUsedBy(int index)
This method return an array that rapresent in which classes a method is called.
Parameters:
index - index of method
Throws:
ArrayIndexOutOfBoundsException - thrown when the index reified doesn't exist in bUsedMethods.

numberOfFields

public int numberOfFields()
This method return the number of fields stored.
Returns:
size of ojFields.

fieldAt

public OJField fieldAt(int index)
This method return the OJField object specified by index.
Parameters:
index - index of element to return
Returns:
the field at given index.
Throws:
ArrayIndexOutOfBoundsException - thrown when the index reified doesn't exist in ojFields.

fieldUsedBy

public boolean fieldUsedBy(int index,
                           int className)
This method check if a field is used in a class.
Parameters:
index - index of field to be checked
className - a number that representing name of class to check if field is used in
Returns:
true if field at specified index is used by specified class
Throws:
ArrayIndexOutOfBoundsException - thrown when the index reified doesn't exist in bUsedFields.

fieldUsedBy

public int[] fieldUsedBy(int index)
This method return an array that rapresent in which classes the field is used.
Parameters:
index - index of method
Returns:
array of three elements indicating in which classes the field is used.
Throws:
ArrayIndexOutOfBoundsException - thrown when the index reified doesn't exist in bUsedFields.

insertMethod

public boolean insertMethod(OJMethod Method,
                            int className)
Put a method in the graph. If the spedified method isn't already present in ojMethods this method adds it and sets bUsedMethod field, otherwise it only update bUsedMethod.
Parameters:
Method - method to insert into the graph.
className - a number that representing class that use the method.
Throws:
ArrayIndexOutOfBoundsException - thrown when the classname reified is grater than three

insertFields

public void insertFields(OJField Fields,
                         int[] classesName)
Put a field in the graph. If the spedified fields isn't already present in ojFields add it and set bUsed, otherwise it only update bUsed
Parameters:
Method - method to insert in the graph
className - a number that representing class that use the method
Throws:
ArrayIndexOutOfBoundsException - thrown when the classname reified is grater than three

DangerousFields

public java.util.Vector DangerousFields()
This method checks if fields are dangerous, in other words it control if a fields is used by more than one class.
Returns:
array that contains all dangerous methods.