uk.ac.liv.auction.core
Class AuctionImpl

java.lang.Object
  extended byjava.util.Observable
      extended byuk.ac.liv.auction.core.AuctionImpl
All Implemented Interfaces:
Auction, QuoteProvider, Resetable, java.io.Serializable
Direct Known Subclasses:
RoundRobinAuction

public abstract class AuctionImpl
extends java.util.Observable
implements Auction, java.io.Serializable, Resetable

An abstract implementation of Auction that provides basic logging facilities.

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

Field Summary
protected  Auctioneer auctioneer
          The plugable auction rules to use for this auction, e.g.
protected  boolean closed
          Flag indicating whether the auction is currently closed.
protected  java.util.HashMap eventListeners
           
protected  long id
          A unique id for this auction.
protected  Shout lastAsk
          The last ask placed in the auction.
protected  Shout lastBid
          The last bid placed in the auction.
protected  Shout lastShout
          The last shout placed in the auction.
protected  java.lang.String name
          The name of this auction.
protected  AuctionReport report
          The optional MarketDataLogger to log data to.
 
Constructor Summary
AuctionImpl()
           
AuctionImpl(java.lang.String name)
           
 
Method Summary
 void addAuctionEventListener(AuctionEventListener listener)
           
 void addAuctionEventListener(java.lang.Class eventClass, AuctionEventListener listener)
           
 void addListener(java.util.LinkedList listeners, AuctionEventListener listener)
           
 void addReport(AuctionReport newReport)
          Add a new market data logger.
 void close()
          Close the auction.
 boolean closed()
          Returns true if the auction is closed.
protected  void fireEvent(AuctionEvent event)
           
 Auctioneer getAuctioneer()
          Return the current auctioneer for this auction.
 Shout getLastShout()
          Return the last shout placed in the auction.
 java.lang.String getName()
           
 MarketQuote getQuote()
           
 AuctionReport getReport()
          Get the current data logger
 AuctionReport getReport(java.lang.Class reportClass)
           
 java.util.Map getResults()
          Return a Map of all of the variables in all of the reports configured for this auction.
 void informAuctionClosed()
           
 void informAuctionOpen()
           
 void informEndOfDay()
           
protected  void initialise()
           
 void newShout(Shout shout)
          Handle a new shout in the auction.
 void printState()
          Report the state of the auction.
protected  void recordShout(Shout shout)
           
 void removeAuctionEventListener(AuctionEventListener listener)
           
 void removeAuctionEventListener(java.lang.Class eventClass, AuctionEventListener listener)
           
 void removeShout(Shout shout)
          Remove a shout from the auction.
 void reset()
          Reinitialise our state to the original settings.
 void setAuctioneer(Auctioneer auctioneer)
           
 void setName(java.lang.String name)
          Change the name of this auction.
 void setReport(AuctionReport logger)
          Assign a data logger
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface uk.ac.liv.auction.core.Auction
clear, getDay, getNumberOfTraders, getRemainingTime, getRound, shoutAccepted, transactionsOccured
 

Field Detail

name

protected java.lang.String name
The name of this auction.


id

protected long id
A unique id for this auction. It's main use is in debugging.


lastShout

protected Shout lastShout
The last shout placed in the auction.


lastBid

protected Shout lastBid
The last bid placed in the auction.


lastAsk

protected Shout lastAsk
The last ask placed in the auction.


closed

protected boolean closed
Flag indicating whether the auction is currently closed.


auctioneer

protected Auctioneer auctioneer
The plugable auction rules to use for this auction, e.g. AscendingAuctioneer.


report

protected AuctionReport report
The optional MarketDataLogger to log data to.


eventListeners

protected java.util.HashMap eventListeners
Constructor Detail

AuctionImpl

public AuctionImpl(java.lang.String name)

AuctionImpl

public AuctionImpl()
Method Detail

initialise

protected void initialise()

reset

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

Specified by:
reset in interface Resetable

setAuctioneer

public void setAuctioneer(Auctioneer auctioneer)

getAuctioneer

public Auctioneer getAuctioneer()
Description copied from interface: Auction
Return the current auctioneer for this auction.

Specified by:
getAuctioneer in interface Auction

closed

public boolean closed()
Description copied from interface: Auction
Returns true if the auction is closed.

Specified by:
closed in interface Auction

close

public void close()
Close the auction.

Specified by:
close in interface Auction

getLastShout

public Shout getLastShout()
                   throws ShoutsNotVisibleException
Description copied from interface: Auction
Return the last shout placed in the auction.

Specified by:
getLastShout in interface Auction
Throws:
ShoutsNotVisibleException

setReport

public void setReport(AuctionReport logger)
Assign a data logger


getReport

public AuctionReport getReport()
Get the current data logger


setName

public void setName(java.lang.String name)
Change the name of this auction.

Parameters:
name - The new name of the auction.

getQuote

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

getName

public java.lang.String getName()

removeShout

public void removeShout(Shout shout)
Description copied from interface: Auction
Remove a shout from the auction.

Specified by:
removeShout in interface Auction

newShout

public void newShout(Shout shout)
              throws AuctionException
Handle a new shout in the auction.

Specified by:
newShout in interface Auction
Parameters:
shout - The new shout in the auction.
Throws:
AuctionException

recordShout

protected void recordShout(Shout shout)

printState

public void printState()
Description copied from interface: Auction
Report the state of the auction.

Specified by:
printState in interface Auction

addReport

public void addReport(AuctionReport newReport)
Add a new market data logger.

Parameters:
newReport - The new logger to add.

addListener

public void addListener(java.util.LinkedList listeners,
                        AuctionEventListener listener)

addAuctionEventListener

public void addAuctionEventListener(AuctionEventListener listener)

removeAuctionEventListener

public void removeAuctionEventListener(AuctionEventListener listener)

addAuctionEventListener

public void addAuctionEventListener(java.lang.Class eventClass,
                                    AuctionEventListener listener)

removeAuctionEventListener

public void removeAuctionEventListener(java.lang.Class eventClass,
                                       AuctionEventListener listener)

fireEvent

protected void fireEvent(AuctionEvent event)

informAuctionClosed

public void informAuctionClosed()

informEndOfDay

public void informEndOfDay()

informAuctionOpen

public void informAuctionOpen()

getResults

public java.util.Map getResults()
Return a Map of all of the variables in all of the reports configured for this auction. The Map maps report variables, represented as objects of type ReportVariable onto their values.

See Also:
ReportVariable

getReport

public AuctionReport getReport(java.lang.Class reportClass)
Specified by:
getReport in interface Auction

toString

public java.lang.String toString()