marketplace
Class SellerAgent

java.lang.Object
  |
  +--ciagent.CIAgent
        |
        +--marketplace.SellerAgent
Direct Known Subclasses:
BestSellerAgent, BetterSellerAgent

public class SellerAgent
extends CIAgent

The SellerAgent class implements a very simple seller agent.

See Also:
Serialized Form

Field Summary
protected  BasicNegotiation current
           
protected  long income
           
protected  java.util.Vector inventory
           
protected  BuySellMessage msg
           
protected  java.util.Hashtable negotiations
           
 
Fields inherited from class ciagent.CIAgent
agentPlatform, children, DEFAULT_ASYNCTIME, DEFAULT_SLEEPTIME, name, parent, traceLevel
 
Constructor Summary
SellerAgent()
          Creates a SellerAgent object.
SellerAgent(java.lang.String name)
          Creates a SellerAgent object with the given name.
 
Method Summary
(package private)  java.lang.String genId()
          Generates a unique id for an item in inventory.
 java.lang.String getTaskDescription()
          Retrieves the task description that indicates what this agent is doing.
 void initialize()
          Registers with the facilitator, initalizes its inventory, and advertises the items it has for sale.
(package private)  boolean itemInInventory(java.lang.String item)
          Checks if an item is in inventory
(package private)  void negotiate(Offer offer, BuySellMessage msg)
          Negotiates by accepting or rejecting offers.
 void process()
          Does nothing.
 void processCIAgentEvent(CIAgentEvent e)
          Processes a CIAgentEvent.
 void processMessage(BuySellMessage msg)
          Processes the BuySellMessage received in a CIAgentEvent object.
 void processTimerPop()
          Processes a timer pop by displaying a trace message.
(package private)  void rejectOffer(Offer offer)
          Breaks off a negotiation (for whatever reason), returns the item to inventory, and removes the negotiation from the active list.
(package private)  BasicNegotiation removeItemFromInventory(java.lang.String item)
          Removes an item from inventory.
 
Methods inherited from class ciagent.CIAgent
addAgent, addCIAgentEventListener, addPropertyChangeListener, getAgent, getAgentPlatform, getAgents, getAsyncTime, getChildren, getCustomizerClass, getDisplayName, getName, getParent, getSleepTime, getState, getTraceLevel, notifyCIAgentEventListeners, postCIAgentEvent, processAsynchronousEvents, removeAgent, removeCIAgentEventListener, removePropertyChangeListener, reset, resumeAgentProcessing, setAgentPlatform, setAsyncTime, setName, setParent, setSleepTime, setState, setTraceLevel, startAgentProcessing, stopAgentProcessing, suspendAgentProcessing, trace
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msg

protected BuySellMessage msg

current

protected BasicNegotiation current

income

protected long income

inventory

protected java.util.Vector inventory

negotiations

protected java.util.Hashtable negotiations
Constructor Detail

SellerAgent

public SellerAgent()
Creates a SellerAgent object.

SellerAgent

public SellerAgent(java.lang.String name)
Creates a SellerAgent object with the given name.
Parameters:
name - the String object that contains the name of the agent
Method Detail

getTaskDescription

public java.lang.String getTaskDescription()
Retrieves the task description that indicates what this agent is doing.
Returns:
the String object that contains the task description
Overrides:
getTaskDescription in class CIAgent

initialize

public void initialize()
Registers with the facilitator, initalizes its inventory, and advertises the items it has for sale.
Overrides:
initialize in class CIAgent

process

public void process()
Does nothing.
Overrides:
process in class CIAgent

processTimerPop

public void processTimerPop()
Processes a timer pop by displaying a trace message.
Overrides:
processTimerPop in class CIAgent

processCIAgentEvent

public void processCIAgentEvent(CIAgentEvent e)
Processes a CIAgentEvent.
Parameters:
e - the CIAgentEvent object to be processed
Overrides:
processCIAgentEvent in class CIAgent

genId

java.lang.String genId()
Generates a unique id for an item in inventory.
Returns:
the String object that contains the unique id

processMessage

public void processMessage(BuySellMessage msg)
Processes the BuySellMessage received in a CIAgentEvent object.
Parameters:
msg - the BuySellMessage object to be processed

negotiate

void negotiate(Offer offer,
               BuySellMessage msg)
Negotiates by accepting or rejecting offers.
Parameters:
offer - the Offer object for the current offer
msg - the BuySellMessage object

rejectOffer

void rejectOffer(Offer offer)
Breaks off a negotiation (for whatever reason), returns the item to inventory, and removes the negotiation from the active list.
Parameters:
offer - the Offer object that contains the offer being rejected

itemInInventory

boolean itemInInventory(java.lang.String item)
Checks if an item is in inventory
Parameters:
item - the String object that contains the item to be checked
Returns:
returns true if the item is in stock

removeItemFromInventory

BasicNegotiation removeItemFromInventory(java.lang.String item)
Removes an item from inventory.
Parameters:
item - the String object that contains the itme to be removed
Returns:
the BasicNegotiation object containing the item from inventory or null if we have no items