entities
Class Method

java.lang.Object
  extended byentities.Method
All Implemented Interfaces:
ScopeManager

public class Method
extends java.lang.Object
implements ScopeManager

The Method class represents the information regarding a method.


Field Summary
static java.lang.String CONSTRUCTOR
          Used to specify that the method is a constructor
static java.lang.String DESTRUCTOR
          Used to specify that the method is a destructor
static java.lang.String IMPLEMENTED_INSIDE_CLASS
          Used to specify that the method is implemented inside the class
static java.lang.String IMPLEMENTED_OUTSIDE_CLASS
          Used to specify that the method is not implemented outside the class
static java.lang.String NORMAL
          Used to specify that the method is a normal method (not a constructor and not a destructor)
static java.lang.String NOT_IMPLEMENTED
          Used to specify that the method is not implemented
 
Constructor Summary
Method(ScopeManager parentScope, java.lang.String className, java.lang.String name, java.lang.String declarationFile, int declarationPosition, java.lang.String type, boolean constFlag, boolean pureVirtual, boolean staticFlag, boolean virtualFlag, boolean inlineFlag, boolean returnedValueConst, java.lang.String accessType, java.lang.String returnedType, java.util.Vector parameters)
          Construct a new Method
 
Method Summary
 void addClass(ClassEntity cl)
          Empty
 void addClassHeaderFile(java.lang.String className, java.lang.String headerFileName)
          Empty
 void addEnumerator(Enumerator en)
          Add an Enumerator object to the method
 void addExpression(Expression expr, ScopeManager wrapper)
          Add a statement (of type Expression) to the body of the method
 void addExternalField(Variable variable)
          Empty
 void addExternalMethod(Method method)
          Empty
 void addField(Variable variable)
          Empty
 void addFriendClass(Variable variable)
          Empty
 void addFriendFunction(Function function)
          Empty
 void addFriendMethod(Method method)
          Empty
 void addFunction(Function function)
          Empty
 void addGeneralization(SuperClass superClass)
          Empty
 void addInitializer(Initializer initializer)
          Add an Initializer object to the method
 void addMethod(Method method)
          Empty
 void addNameSpace(NameSpace namespace)
          Empty
 void addType(java.lang.String name, java.lang.String type)
          Empty
 void addUserType(java.lang.String name, java.lang.String type)
          Add a new type defined using typedef to the user types.
 void addVariable(Variable var)
          Add a Variable to the local variable of the method
 boolean areExceptionUsed()
           
static void createTable(java.sql.Connection dbConnection)
           
static void delete(java.sql.Connection dbConnection, int id)
           
 ScopeManager findVariableType(java.lang.String nameToBeFound, java.lang.StringBuffer typeToBeFound, Expression expr)
          Look for the variable declaration whose name is "nameToBeFound" and return the ScopeManager in which it is defined (if found), filling "typeToBeFound" with the variable type.
 java.lang.String getAccessType()
           
 java.util.Vector getBody()
           
 java.lang.String getClassName()
           
 Method getCurrentMethod(java.lang.String methodName, java.util.Vector parameters)
           
 java.lang.String getDeclarationFile()
           
 int getDeclarationPosition()
           
 java.lang.String getDefinitionFile()
           
 Parameter getDefinitionParameter(java.lang.String parameterName)
           
 java.util.Vector getDefinitionParameters()
           
 int getDefinitionPosition()
           
 int getEndLine()
           
 java.util.Vector getEnumerators()
           
 java.lang.String getImplementation()
           
 java.util.Vector getInitializers()
           
 int getInitLine()
           
 java.util.Vector getLocalVariables()
           
 java.lang.String getName()
           
 java.util.Vector getParameters()
           
 java.lang.String getParameterTypesAsString()
           
 ScopeManager getParent()
           
 java.lang.String getReturnedType()
           
 java.lang.String getSignature()
           
 java.util.Vector getThrownExceptions()
           
 java.util.Vector getThrownExceptionsinInDefinition()
           
 java.lang.String getType()
           
 java.util.Hashtable getTypeTable()
           
 java.util.Hashtable getUserTypeTable()
           
 void insert(java.sql.Connection dbConnection, int sourceId, int sourceType)
           
 boolean isATemplate()
           
 boolean isConst()
           
 boolean isImplementedInsideClass()
           
 boolean isImplementedOutsideClass()
           
 boolean isInitialized()
           
 boolean isInline()
           
 boolean isPureVirtual()
           
 boolean isStatic()
           
 boolean isTheReducedSignatureEqual(java.lang.String name, java.util.Vector parameters)
           
 boolean isTheSignatureEqual(java.lang.String name, java.lang.String returnedType, java.util.Vector parameters, java.lang.String type)
           
 boolean isTheSignatureEqual1(java.lang.String name, java.lang.String returnedType, java.util.Vector parameters, java.lang.String type)
           
 boolean isVirtual()
           
 void print(java.lang.String indentation)
          Print all information
 boolean returnsAConstValue()
           
 void setDefinitionFile(java.lang.String defFile)
           
 void setDefinitionParameters(java.util.Vector parameters)
          The parameter "parameters" represent the formal parameters of the method used when the method is defined
 void setDefinitionPosition(int defPosition)
           
 void setEndLine(int end)
           
 void setExceptionFlag(boolean exceptionFlag)
           
 void setImplementation(java.lang.String implementationPosition)
           
 void setInitializationFlag(boolean initializationFlag)
           
 void setInitLine(int init)
           
 void setInlineFlag(boolean inlineFlag)
           
 void setTemplateFlag(boolean templateFlag)
           
 void setThrownExceptions(java.util.Vector thrownExceptions)
          set the Vector containing the names of exceptions thrown by the function
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTRUCTOR

public static final java.lang.String CONSTRUCTOR
Used to specify that the method is a constructor

See Also:
Constant Field Values

DESTRUCTOR

public static final java.lang.String DESTRUCTOR
Used to specify that the method is a destructor

See Also:
Constant Field Values

NORMAL

public static final java.lang.String NORMAL
Used to specify that the method is a normal method (not a constructor and not a destructor)

See Also:
Constant Field Values

NOT_IMPLEMENTED

public static final java.lang.String NOT_IMPLEMENTED
Used to specify that the method is not implemented

See Also:
Constant Field Values

IMPLEMENTED_INSIDE_CLASS

public static final java.lang.String IMPLEMENTED_INSIDE_CLASS
Used to specify that the method is implemented inside the class

See Also:
Constant Field Values

IMPLEMENTED_OUTSIDE_CLASS

public static final java.lang.String IMPLEMENTED_OUTSIDE_CLASS
Used to specify that the method is not implemented outside the class

See Also:
Constant Field Values
Constructor Detail

Method

public Method(ScopeManager parentScope,
              java.lang.String className,
              java.lang.String name,
              java.lang.String declarationFile,
              int declarationPosition,
              java.lang.String type,
              boolean constFlag,
              boolean pureVirtual,
              boolean staticFlag,
              boolean virtualFlag,
              boolean inlineFlag,
              boolean returnedValueConst,
              java.lang.String accessType,
              java.lang.String returnedType,
              java.util.Vector parameters)
Construct a new Method

Parameters:
parentScope - parent entity object
className - Name of the class
name - Name of the method
declarationFile - Name of the file in which the method is declared
declarationPosition - Position of the method in the file in which it is declared
type - The type of the method (CONSTRUCTOR, DESTRUCTOR, NORMAL)
constFlag - Flag that says if the method is const
pureVirtual - Flag that says if the method is pureVirtual
staticFlag - Flag that says if the method is static
virtualFlag - Flag that says if the method is virtual
inlineFlag - Flag that says if the method has the inline keyword
returnedValueConst - Flag that says if the returned value is constant
accessType - Type of access of the method
returnedType - Type returned by the method
parameters - Vectors of Parameter objects corresponding to the method parameters
Method Detail

getClassName

public java.lang.String getClassName()
Returns:
the string containing the name of the class in which the method is declared

getName

public java.lang.String getName()
Specified by:
getName in interface ScopeManager
Returns:
the string corresponding to the name of the method

getDeclarationFile

public java.lang.String getDeclarationFile()
Returns:
the string corresponding to the file name in which the method is declared

getDeclarationPosition

public int getDeclarationPosition()
Returns:
an integer corresponding to the position (the line) of the method name in the declaration file

getDefinitionFile

public java.lang.String getDefinitionFile()
Returns:
the string corresponding to the file in which the method is defined. It returns null if the method is not implemented.

getDefinitionPosition

public int getDefinitionPosition()
Returns:
an integer corresponding to the position (the line) of the method name in the definition file. It returns -1 if the method is not implemented. (NB: If the method is automatically created by a macro the returned value corresponds to the macro position)

getType

public java.lang.String getType()
Returns:
the string corresponding to the type of the method (CONSTRUCTOR, DESTRUCTOR, NORMAL)

getReturnedType

public java.lang.String getReturnedType()
Returns:
the string containing the type returned by the method

getLocalVariables

public java.util.Vector getLocalVariables()
Returns:
The Vector of objects (of type Variable) that represent the local variables of the method

getAccessType

public java.lang.String getAccessType()
Returns:
the string corresponding to the access type of the method (public, protected, private)

getParameters

public java.util.Vector getParameters()
Returns:
the Vector of objects of type Parameter corresponding to the formal parameters in the method declaration, or an empty Vector if the method does not have parameters

getDefinitionParameters

public java.util.Vector getDefinitionParameters()
Returns:
the Vector of objects of type Parameter corresponding to the formal parameters in the method definition, or null if the method is not implemented.

getDefinitionParameter

public Parameter getDefinitionParameter(java.lang.String parameterName)
Returns:
the object (of type Parameter) whose name is "parameterName" if it exists, null otherwise.

getParameterTypesAsString

public java.lang.String getParameterTypesAsString()
Returns:
a string containing the types of the parameters separated by a ","

getSignature

public java.lang.String getSignature()
Returns:
the string containing the signature of the function in UML format

getEnumerators

public java.util.Vector getEnumerators()
Returns:
a Vector of objects of type Enumerator
See Also:
Enumerator

getImplementation

public java.lang.String getImplementation()
Returns:
a string which specifies if the method is implemented, if is implemented inside the class or if is implemented outside the class (IMPLEMENTED_INSIDE_CLASS, IMPLEMENTED_INSIDE_CLASS, NOT_IMPLEMENTED)

getInitLine

public int getInitLine()
Returns:
the line position of the first "{". It returns -1 if the method is not implemented

getEndLine

public int getEndLine()
Returns:
the line position of the last "}". It returns -1 if the method is not implemented

getBody

public java.util.Vector getBody()
Returns:
a Vector of objects of type Expression corresponding to the statements of the method.

getTypeTable

public java.util.Hashtable getTypeTable()
Returns:
a Hashtable containing all the new types defined using the typedef statement (the key is the new name)

getUserTypeTable

public java.util.Hashtable getUserTypeTable()
Returns:
a Hashtable containing the new types defined by the user using the typedef statement (the key is the new name)

getParent

public ScopeManager getParent()
Specified by:
getParent in interface ScopeManager
Returns:
the parent ScopeManager

getThrownExceptions

public java.util.Vector getThrownExceptions()
Returns:
the Vector containing the objects (of type String) corresponding to the exceptions thrown by the method
 Ex: class A {void h () throw (Range_Error)};
 
In this case it returns a Vector containing an object (of type String) corresponding to the string "Range_Error".

getThrownExceptionsinInDefinition

public java.util.Vector getThrownExceptionsinInDefinition()
Returns:
the Vector containing the objects (of type String) corresponding to the exceptions thrown by the function
 Ex: class A {void h ()}; A::h() throw (Range_Error) {..} ;
 
In this case it returns a Vector containing an object (of type String) corresponding to the string "Range_Error".

getCurrentMethod

public Method getCurrentMethod(java.lang.String methodName,
                               java.util.Vector parameters)
Specified by:
getCurrentMethod in interface ScopeManager
Returns:
The method was name is "methodName" and whose parameter are specified in the Vector parameters

getInitializers

public java.util.Vector getInitializers()
Returns:
the Vector containing the objects (of type Initializer) corresponding to the initializer
 Ex: class Manager : Employee {
        int level;
      public:
        Manager( const string& n, int d, int l);
     };
 
 Manager::Manager(const string& n, int d, int l): Employee(n, d), level(l) { }
 
 
In this case it returns a Vector containing two objects (of type Initializer) one corresponding to "Employee" and the second corresponding to "level".

isConst

public boolean isConst()
Returns:
true if the method is constant

isStatic

public boolean isStatic()
Returns:
true if the method is static

isInline

public boolean isInline()
Returns:
true if the keyword inline is present

isPureVirtual

public boolean isPureVirtual()
Returns:
true if the method is pureVirtual

isVirtual

public boolean isVirtual()
Returns:
true if the method is virtual

isATemplate

public boolean isATemplate()
Returns:
true if the method is a template

areExceptionUsed

public boolean areExceptionUsed()
Returns:
true is exceptions are used

isInitialized

public boolean isInitialized()
Returns:
true if the method is initialized

returnsAConstValue

public boolean returnsAConstValue()
Returns:
true if the returned value is const

isTheSignatureEqual1

public boolean isTheSignatureEqual1(java.lang.String name,
                                    java.lang.String returnedType,
                                    java.util.Vector parameters,
                                    java.lang.String type)
Parameters:
name - String corresponding to a method name
returnedType - String corresponding to the returned type of the method
parameters - Vector containing the Parameter objects of the method
type - String corresponding to the method type (CONSTRUCTOR, DESTRUCTOR, NORMAL)
Returns:
true in case the method matches

isTheSignatureEqual

public boolean isTheSignatureEqual(java.lang.String name,
                                   java.lang.String returnedType,
                                   java.util.Vector parameters,
                                   java.lang.String type)
Parameters:
name - String corresponding to a method name
returnedType - String corresponding to the returned type of the method
parameters - Vector containing the Parameter objects of the method
type - String corresponding to the method type (CONSTRUCTOR, DESTRUCTOR, NORMAL)
Returns:
true in case the method matches

isTheReducedSignatureEqual

public boolean isTheReducedSignatureEqual(java.lang.String name,
                                          java.util.Vector parameters)
Parameters:
name - String corresponding to a method name
parameters - Vector containing the Parameter objects of the method
Returns:
true in case the method matches

isImplementedInsideClass

public boolean isImplementedInsideClass()
Returns:
true if the method is implemented inside the class

isImplementedOutsideClass

public boolean isImplementedOutsideClass()
Returns:
true if the method is implemented outside the class

addEnumerator

public void addEnumerator(Enumerator en)
Add an Enumerator object to the method

Specified by:
addEnumerator in interface ScopeManager

addInitializer

public void addInitializer(Initializer initializer)
Add an Initializer object to the method


setThrownExceptions

public void setThrownExceptions(java.util.Vector thrownExceptions)
set the Vector containing the names of exceptions thrown by the function


addNameSpace

public void addNameSpace(NameSpace namespace)
Empty

Specified by:
addNameSpace in interface ScopeManager

addExpression

public void addExpression(Expression expr,
                          ScopeManager wrapper)
Add a statement (of type Expression) to the body of the method

Specified by:
addExpression in interface ScopeManager

addClass

public void addClass(ClassEntity cl)
Empty

Specified by:
addClass in interface ScopeManager

addFunction

public void addFunction(Function function)
Empty

Specified by:
addFunction in interface ScopeManager

addMethod

public void addMethod(Method method)
Empty

Specified by:
addMethod in interface ScopeManager

addVariable

public void addVariable(Variable var)
Add a Variable to the local variable of the method

Specified by:
addVariable in interface ScopeManager

addField

public void addField(Variable variable)
Empty

Specified by:
addField in interface ScopeManager

addType

public void addType(java.lang.String name,
                    java.lang.String type)
Empty

Specified by:
addType in interface ScopeManager

addUserType

public void addUserType(java.lang.String name,
                        java.lang.String type)
Add a new type defined using typedef to the user types.

Specified by:
addUserType in interface ScopeManager

addGeneralization

public void addGeneralization(SuperClass superClass)
Empty

Specified by:
addGeneralization in interface ScopeManager

addExternalMethod

public void addExternalMethod(Method method)
Empty

Specified by:
addExternalMethod in interface ScopeManager

addExternalField

public void addExternalField(Variable variable)
Empty

Specified by:
addExternalField in interface ScopeManager

addFriendFunction

public void addFriendFunction(Function function)
Empty

Specified by:
addFriendFunction in interface ScopeManager

addFriendMethod

public void addFriendMethod(Method method)
Empty

Specified by:
addFriendMethod in interface ScopeManager

addFriendClass

public void addFriendClass(Variable variable)
Empty

Specified by:
addFriendClass in interface ScopeManager

addClassHeaderFile

public void addClassHeaderFile(java.lang.String className,
                               java.lang.String headerFileName)
Empty

Specified by:
addClassHeaderFile in interface ScopeManager

setDefinitionParameters

public void setDefinitionParameters(java.util.Vector parameters)
The parameter "parameters" represent the formal parameters of the method used when the method is defined


setDefinitionFile

public void setDefinitionFile(java.lang.String defFile)
Parameters:
defFile - is name of the file in which the method is defined

setDefinitionPosition

public void setDefinitionPosition(int defPosition)
Parameters:
defPosition - represents the position (line) of the method name in the file

setImplementation

public void setImplementation(java.lang.String implementationPosition)
Parameters:
implementationPosition - specifies if the the method is implemented, if is implemented inside the class or if is implemented outside the class (IMPLEMENTED_INSIDE_CLASS, IMPLEMENTED_INSIDE_CLASS, NOT_IMPLEMENTED)

setInitLine

public void setInitLine(int init)
Parameters:
init - represents the line position of the first "{".

setEndLine

public void setEndLine(int end)
Parameters:
end - represents the line position of the last "}".

setInlineFlag

public void setInlineFlag(boolean inlineFlag)

setTemplateFlag

public void setTemplateFlag(boolean templateFlag)
Parameters:
templateFlag - is true if the method is a template method

setExceptionFlag

public void setExceptionFlag(boolean exceptionFlag)
Parameters:
exceptionFlag - is true if the method throws an exception

setInitializationFlag

public void setInitializationFlag(boolean initializationFlag)
Parameters:
initializationFlag - is true if the method is initialized

print

public void print(java.lang.String indentation)
Print all information

Specified by:
print in interface ScopeManager

findVariableType

public ScopeManager findVariableType(java.lang.String nameToBeFound,
                                     java.lang.StringBuffer typeToBeFound,
                                     Expression expr)
Look for the variable declaration whose name is "nameToBeFound" and return the ScopeManager in which it is defined (if found), filling "typeToBeFound" with the variable type.

Specified by:
findVariableType in interface ScopeManager

delete

public static void delete(java.sql.Connection dbConnection,
                          int id)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

createTable

public static void createTable(java.sql.Connection dbConnection)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

insert

public void insert(java.sql.Connection dbConnection,
                   int sourceId,
                   int sourceType)
            throws java.sql.SQLException
Throws:
java.sql.SQLException