org.virtualmock.call
Class CallQueue

java.lang.Object
  extended byorg.virtualmock.call.CallQueue
Direct Known Subclasses:
InvokedCallQueue, RecordedCallQueue

public class CallQueue
extends java.lang.Object

This class represents a sequence of calls. Calls added are stored sequentially, and can be retrieved in same order they were added. Calls can also be retrieved by Signature. Utility methods are also provided to manage the queue.

Author:
Chad Woolley

Constructor Summary
CallQueue()
           
 
Method Summary
 void add(Call call)
          Adds a new call to the end of the queue, and also sets the signatureSequence for the call.
 void clear()
          Reinitialize by clearing out all calls.
 Call getCallByCallId(java.lang.String callId)
          Gets a call based on the callId.
 java.util.List getCalls()
          Get all calls that have been added, in order.
 Call getFirstCallWithMatchingSignature(Signature signature)
          Gets the first call in the queue which has a signature matching the parameter.
protected  int getIndexOfFirstCallWithMatchingSignature(Signature signature)
          Gets the index of the first call which has the same signature.
 int getIndexOfNextCallWithMatchingSignature(int startIndex, Signature signature)
          Gets the index of the next call in the queue which has a signature matching the parameter, starting at the specified index.
 int getMatchingSignatureCount(Signature signature)
          Returns the number of calls in the queue with the specified signature.
 Call getNextCallWithMatchingSignature(int startIndex, Signature signature)
          Gets the next call in the queue which has a signature matching the parameter, starting at the specified index.
protected  java.util.List getSignatures()
          Get the signatures for all the calls in the queue, in the same order as the calls.
 boolean hasCallWithMatchingSignature(Call call)
          Indicates if the queue has a call matching the specified signature.
 boolean hasCallWithMatchingSignature(Signature signature)
          Indicates if the queue has a call matching the specified signature.
 int size()
          Get the number of calls in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallQueue

public CallQueue()
Method Detail

getCallByCallId

public Call getCallByCallId(java.lang.String callId)
Gets a call based on the callId.

Parameters:
callId - the unique identifier for the call
Returns:
the call which matches the CallId, or null if no match was found.

getCalls

public java.util.List getCalls()
Get all calls that have been added, in order.

Returns:
all calls that have been added

getFirstCallWithMatchingSignature

public Call getFirstCallWithMatchingSignature(Signature signature)
Gets the first call in the queue which has a signature matching the parameter.

Parameters:
signature - the signature used to look up the call
Returns:
the first call in the queue which has a signature matching the parameter

getIndexOfNextCallWithMatchingSignature

public int getIndexOfNextCallWithMatchingSignature(int startIndex,
                                                   Signature signature)
Gets the index of the next call in the queue which has a signature matching the parameter, starting at the specified index.

Parameters:
startIndex - the index to start looking at
signature - the signature used to look up the call
Returns:
the next call in the queue which has a signature matching the parameter, or null if no match is found

getMatchingSignatureCount

public int getMatchingSignatureCount(Signature signature)
Returns the number of calls in the queue with the specified signature.

Parameters:
signature - the signature to match
Returns:
the number of calls in the queue with the specified signature

getNextCallWithMatchingSignature

public Call getNextCallWithMatchingSignature(int startIndex,
                                             Signature signature)
Gets the next call in the queue which has a signature matching the parameter, starting at the specified index.

Parameters:
startIndex - the index to start looking at
signature - the signature used to look up the call
Returns:
the next call in the queue which has a signature matching the parameter, or null if no match is found

add

public void add(Call call)
Adds a new call to the end of the queue, and also sets the signatureSequence for the call.

Parameters:
call - a call to add to the queue

clear

public void clear()
Reinitialize by clearing out all calls.


hasCallWithMatchingSignature

public boolean hasCallWithMatchingSignature(Signature signature)
Indicates if the queue has a call matching the specified signature.

Parameters:
signature - the signature to match
Returns:
true if the queue has a call matching the specified signature

hasCallWithMatchingSignature

public boolean hasCallWithMatchingSignature(Call call)
Indicates if the queue has a call matching the specified signature.

Parameters:
call - the call to match
Returns:
true if the queue has a call matching the specified signature

size

public int size()
Get the number of calls in the queue.

Returns:
the number of calls in the queue

getIndexOfFirstCallWithMatchingSignature

protected int getIndexOfFirstCallWithMatchingSignature(Signature signature)
Gets the index of the first call which has the same signature.

Parameters:
signature - The signature to match on
Returns:
the index of the first call which has the same signature

getSignatures

protected java.util.List getSignatures()
Get the signatures for all the calls in the queue, in the same order as the calls.

Returns:
Get the signatures for all the calls in the queue, in the same order as the calls.


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