org.virtualmock.call
Class Signature

java.lang.Object
  extended byorg.virtualmock.call.Signature

public class Signature
extends java.lang.Object

The signature for a method call, representing the class, method name, and classes of the arguments. It is NOT a unique identifier for a call, since multiple calls can be recorded for the same signature.

Version:
$Revision: 1.14 $
Author:
Chad Woolley

Constructor Summary
Signature(java.lang.Class returnType, java.lang.Class classType, java.lang.String methodName)
          Creates a new Signature object with a return value but no arguments.
Signature(java.lang.Class returnType, java.lang.Class classType, java.lang.String methodName, java.lang.Class[] argTypes)
          Creates a new Signature object with a return value and arguments.
Signature(java.lang.Class classType, java.lang.String methodName)
          Creates a new Signature object with no return value or arguments.
Signature(java.lang.Class classType, java.lang.String methodName, java.lang.Class[] argTypes)
          Creates a new Signature object with no return value but with arguments.
 
Method Summary
protected  void create(java.lang.Class newReturnType, java.lang.Class newClassType, java.lang.String newMethodName, java.lang.Class[] newArgTypes)
          Internal method which contains the logic to create a signature.
 boolean equals(java.lang.Object object)
          Compares this Signature to another object.
 java.lang.Class[] getArgTypes()
          Accessor.
 java.lang.String getClassName()
          Returns the name of the class type of this Signature.
 java.lang.Class getClassType()
          Accessor.
 java.lang.String getMethodName()
          Accessor.
 java.lang.Class getReturnType()
          Accessor.
 int hashCode()
          Return hashCode for this Signature.
 boolean isAssignableFrom(Signature signature)
           This method is similar to Java's Class.isAssignableFrom() method, but it checks the class type, method name and each individual argument type for this Signature.
 boolean isReturnTypePrimitive()
          Returns true is return type is primitive.
 java.lang.String toString()
          Represents this signature as a String.
protected  java.lang.String toStringWithoutReturnType()
          Returns the representation of the Signature as a string, with the return type omitted.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Signature

public Signature(java.lang.Class returnType,
                 java.lang.Class classType,
                 java.lang.String methodName,
                 java.lang.Class[] argTypes)
Creates a new Signature object with a return value and arguments.

Parameters:
returnType - The type of the return value for this signature
classType - The type of the class which owns this signature
methodName - The name of the method for this signature
argTypes - Class array representing the argument types, or null if there are no arguments.

Signature

public Signature(java.lang.Class returnType,
                 java.lang.Class classType,
                 java.lang.String methodName)
Creates a new Signature object with a return value but no arguments.

Parameters:
returnType - The type of the return value for this signature
classType - The type of the class which owns this signature
methodName - The name of the method for this signature

Signature

public Signature(java.lang.Class classType,
                 java.lang.String methodName,
                 java.lang.Class[] argTypes)
Creates a new Signature object with no return value but with arguments.

Parameters:
classType - The type of the class which owns this signature
methodName - The name of the method for this signature
argTypes - Class array representing the argument types, or null if there are no arguments.

Signature

public Signature(java.lang.Class classType,
                 java.lang.String methodName)
Creates a new Signature object with no return value or arguments.

Parameters:
classType - The type of the class which owns this signature
methodName - The name of the method for this signature
Method Detail

getArgTypes

public java.lang.Class[] getArgTypes()
Accessor.

Returns:
An array of Class objects representing the argument types for this signature, or an empty array if there are no arguments for this signature.

isAssignableFrom

public boolean isAssignableFrom(Signature signature)

This method is similar to Java's Class.isAssignableFrom() method, but it checks the class type, method name and each individual argument type for this Signature.

To paraphrase the javadoc for Class.isAssignableFrom(): "Determines if all argument types contained in this Signature object are either the same as, or are superclasses or superinterfaces of, the argument types of the Signature represented by the specified call parameter. It returns true if so; otherwise it returns false. If the argument types of this Signature object represent primitive types, the method returns true if the specified argument types of the Signature parameter are exactly this Calls argument objects; otherwise it returns false."

Parameters:
signature - the Signature which will be checked against this Signature
Returns:
true if the passed Signature's method name and argument types are assignable to this Signature

getClassName

public java.lang.String getClassName()
Returns the name of the class type of this Signature.

Returns:
the name of the class type of this Signature

getClassType

public java.lang.Class getClassType()
Accessor.

Returns:
the class type of this signature

getMethodName

public java.lang.String getMethodName()
Accessor.

Returns:
the method name of this signature

getReturnType

public java.lang.Class getReturnType()
Accessor.

Returns:
the return type of this signature

isReturnTypePrimitive

public boolean isReturnTypePrimitive()
Returns true is return type is primitive.

Returns:
true is return type is primitive

equals

public boolean equals(java.lang.Object object)
Compares this Signature to another object. Note that this ignores the type of the return value, like Java does.

Parameters:
object - The object with which we are comparing
Returns:
true if the passed object is a Signature that matches this one

hashCode

public int hashCode()
Return hashCode for this Signature.

Returns:
the hashCode for this Signature

toString

public java.lang.String toString()
Represents this signature as a String.

Returns:
This Signature, represented as a String

create

protected void create(java.lang.Class newReturnType,
                      java.lang.Class newClassType,
                      java.lang.String newMethodName,
                      java.lang.Class[] newArgTypes)
Internal method which contains the logic to create a signature.

Parameters:
newReturnType - the returnType which will be used to create this Signature
newClassType - the classType which will be used to create this Signature
newMethodName - the methodName which will be used to create this Signature
newArgTypes - the argTypes which will be used to create this Signature

toStringWithoutReturnType

protected java.lang.String toStringWithoutReturnType()
Returns the representation of the Signature as a string, with the return type omitted.

Returns:
the representation of the Signature as a string, with the return type omitted.


Copyright © 2003-2005 Virtual Mock. All Rights Reserved.