org.brains2b.coffee
Class Ticket

java.lang.Object
  extended by org.brains2b.task.DefaultTask
      extended by org.brains2b.coffee.Ticket
All Implemented Interfaces:
java.lang.Runnable, org.brains2b.task.Task

public class Ticket
extends org.brains2b.task.DefaultTask

A Ticket is created by the TicketBroker as a result of an Event that should be handled through the queue.

The TicketHandler is supplied, so when the Ticket can be handled from the queue it can just process the Event directly

Version:
0.89.1 [29-02-2008]
Author:
dennis@brains2b.nl
See Also:
TicketBroker, TicketFarm, TicketQueue

Nested Class Summary
 class Ticket.Monitor
          Implementation of ProgressMonitor to supply progress information from TicketHandler regarding the running Task to this Ticket and TaskListener(s)
 
Field Summary
static int RESULT_REMOVE
          type of result indicating that this Ticket was removed before starting
 
Fields inherited from interface org.brains2b.task.Task
RESULT_ERROR, RESULT_OK, RESULT_WARNING
 
Constructor Summary
Ticket(TicketHandler server, CoffeeEvent event)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object obj)
          two tickets are considered equal if they have the same sequence number
 java.lang.String getDescription()
           
 CoffeeEvent getEvent()
          the CoffeeEvent which lead to creating this Ticket
 NNTPMessage getMessage()
          the NNTPMessage which was is the result of this Ticket
 int getSequence()
          get the sequence of the Ticket
 TicketHandler getTicketHandler()
          get the TicketHandler which will handle this Ticket
 boolean isWait()
          check if this Ticket is paused
 void run()
           
 void setResult(int result)
          overridden to make public for TicketQueue
 void setWait(boolean wait)
          set this Ticket to pause, until released
 
Methods inherited from class org.brains2b.task.DefaultTask
addException, addMessage, addTaskListener, fireTaskEvent, getMax, getMessages, getMin, getPosition, getResult, isFinished, progress, progress, removeTaskListener, setFinished, setMax, setMin
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULT_REMOVE

public static final int RESULT_REMOVE
type of result indicating that this Ticket was removed before starting

See Also:
Constant Field Values
Constructor Detail

Ticket

public Ticket(TicketHandler server,
              CoffeeEvent event)
Constructor

Parameters:
server - TicketHandler
event - CoffeeEvent
Method Detail

run

public void run()

getMessage

public NNTPMessage getMessage()
the NNTPMessage which was is the result of this Ticket

Returns:
NNTPMessage

getEvent

public CoffeeEvent getEvent()
the CoffeeEvent which lead to creating this Ticket

Returns:
CoffeeEvent

getSequence

public int getSequence()
get the sequence of the Ticket

Returns:
int, the sequence

getTicketHandler

public TicketHandler getTicketHandler()
get the TicketHandler which will handle this Ticket

Returns:
TicketHandler

equals

public boolean equals(java.lang.Object obj)
two tickets are considered equal if they have the same sequence number

Overrides:
equals in class java.lang.Object
Returns:
boolean ture if Tickets are equal

isWait

public boolean isWait()
check if this Ticket is paused

Returns:
boolean, true if paused

setWait

public void setWait(boolean wait)
set this Ticket to pause, until released

Parameters:
wait - boolean, true to wait,false to release

setResult

public void setResult(int result)
overridden to make public for TicketQueue

Overrides:
setResult in class org.brains2b.task.DefaultTask

getDescription

public java.lang.String getDescription()