uk.ac.liv.auction.core
Class AbstractAuctioneer

java.lang.Object
  extended byuk.ac.liv.auction.core.AbstractAuctioneer
All Implemented Interfaces:
Auctioneer, java.lang.Cloneable, Prototypeable, QuoteProvider, Resetable, java.io.Serializable
Direct Known Subclasses:
KAuctioneer

public abstract class AbstractAuctioneer
extends java.lang.Object
implements java.io.Serializable, Auctioneer, Resetable, Prototypeable, java.lang.Cloneable

An abstract class representing an auctioneer managing shouts in an auction. Different auction rules should be encapsulated in different Auctioneer classes.

Version:
$Revision: 1.19 $
Author:
Steve Phelps
See Also:
Serialized Form

Field Summary
protected  Auction auction
          The auction container for this auctioneer.
protected  MarketQuote currentQuote
          The current quote
protected  ShoutEngine shoutEngine
          The shout engine for this auction.
 
Constructor Summary
AbstractAuctioneer()
           
AbstractAuctioneer(Auction auction)
           
 
Method Summary
 java.util.Iterator askIterator()
           
 java.util.Iterator bidIterator()
           
 void endOfDayProcessing()
           
abstract  void generateQuote()
           
 Auction getAuction()
          Find out which auction we are the auctioneer for.
 MarketQuote getQuote()
           
protected  void initialise()
           
protected  void newAsk(Shout ask)
          Default rules for handling a new ask.
protected  void newBid(Shout bid)
          Default rules for handling a new bid.
 void newShout(Shout shout)
          Code for handling a new shout in the auction.
 void printState()
          Log the current state of the auction.
 java.lang.Object protoClone()
           
 void removeShout(Shout shout)
          Handle a request to retract a shout.
 void reset()
          Reinitialise our state to the original settings.
 void setAuction(Auction auction)
          Specify which auction we are the auctioneer for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.liv.auction.core.Auctioneer
clear, endOfAuctionProcessing, endOfRoundProcessing, shoutsVisible
 

Field Detail

auction

protected Auction auction
The auction container for this auctioneer.


shoutEngine

protected ShoutEngine shoutEngine
The shout engine for this auction.


currentQuote

protected MarketQuote currentQuote
The current quote

Constructor Detail

AbstractAuctioneer

public AbstractAuctioneer()

AbstractAuctioneer

public AbstractAuctioneer(Auction auction)
Method Detail

protoClone

public java.lang.Object protoClone()
Specified by:
protoClone in interface Prototypeable

newShout

public void newShout(Shout shout)
              throws IllegalShoutException
Code for handling a new shout in the auction. Subclasses should override this method if they wish to provide different handling for different auction rules.

Specified by:
newShout in interface Auctioneer
Parameters:
shout - The new shout to be processed
Throws:
IllegalShoutException - Thrown if the shout is invalid in some way.

removeShout

public void removeShout(Shout shout)
Handle a request to retract a shout.

Specified by:
removeShout in interface Auctioneer

printState

public void printState()
Log the current state of the auction.

Specified by:
printState in interface Auctioneer

reset

public void reset()
Description copied from interface: Resetable
Reinitialise our state to the original settings.

Specified by:
reset in interface Resetable

initialise

protected void initialise()

getQuote

public MarketQuote getQuote()
Specified by:
getQuote in interface QuoteProvider

askIterator

public java.util.Iterator askIterator()
Specified by:
askIterator in interface Auctioneer

bidIterator

public java.util.Iterator bidIterator()
Specified by:
bidIterator in interface Auctioneer

generateQuote

public abstract void generateQuote()

newAsk

protected void newAsk(Shout ask)
               throws DuplicateShoutException
Default rules for handling a new ask. Subclasses should override this method if they wish to provide different handling for different auction rules.

Parameters:
ask - The new ask (offer to sell) to process
Throws:
DuplicateShoutException

newBid

protected void newBid(Shout bid)
               throws DuplicateShoutException
Default rules for handling a new bid. Subclasses should override this method if they wish to provide different handling for different auction rules.

Parameters:
bid - The new bid (offer to buy) to process
Throws:
DuplicateShoutException

setAuction

public void setAuction(Auction auction)
Description copied from interface: Auctioneer
Specify which auction we are the auctioneer for.

Specified by:
setAuction in interface Auctioneer

getAuction

public Auction getAuction()
Description copied from interface: Auctioneer
Find out which auction we are the auctioneer for.

Specified by:
getAuction in interface Auctioneer

endOfDayProcessing

public void endOfDayProcessing()
Specified by:
endOfDayProcessing in interface Auctioneer