com.monkeycoder.monkeynetwork
Class ProtocolStateEngine

java.lang.Object
  extended by java.util.Observable
      extended by com.monkeycoder.monkeynetwork.ProtocolStateEngine
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FtpStateEngine, HttpStateEngine

public abstract class ProtocolStateEngine
extends java.util.Observable
implements java.lang.Runnable

This is the super-class for protocol state engines. It defines both the start state and the done state.

NOTE: State IDs from 0 to 99 are reserved by this class and should NOT be used by children of this class!

Author:
David Stephens

Field Summary
protected  TurboBuffer content
          The underlying TurboBuffer into which network content will be placed.
protected  java.lang.String fetchUri
          The URI of the content to request.
protected  Network net
          The underlying Network from which network content will be downloaded.
protected  int nextState
          The current state of the engine.
static int STATE_DONE
          Assigned ending state of all ProtocolStateEngine children.
static int STATE_START
          Assigned starting state of all ProtocolStateEngine children.
 
Constructor Summary
ProtocolStateEngine()
          Creates a ProtocolStateEngine.
 
Method Summary
 TurboBuffer getContent()
          Gets the TurboBuffer that was used by the state engine.
abstract  void run()
          Multi-Threaded entry point.
 void setFetchUri(java.lang.String inUri)
          Sets the URI of the content to fetch.
 void setNetwork(Network inNetwork)
          Sets the network from which content will be downloaded.
 
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, toString, wait, wait, wait
 

Field Detail

STATE_START

public static final int STATE_START
Assigned starting state of all ProtocolStateEngine children.

See Also:
Constant Field Values

STATE_DONE

public static final int STATE_DONE
Assigned ending state of all ProtocolStateEngine children.

See Also:
Constant Field Values

net

protected Network net
The underlying Network from which network content will be downloaded.


fetchUri

protected java.lang.String fetchUri
The URI of the content to request.


content

protected TurboBuffer content
The underlying TurboBuffer into which network content will be placed.


nextState

protected int nextState
The current state of the engine. All children must use ProtocolStateEngine.STATE_START to kickstart their engine loop.

Constructor Detail

ProtocolStateEngine

public ProtocolStateEngine()
Creates a ProtocolStateEngine.

Method Detail

setNetwork

public void setNetwork(Network inNetwork)
Sets the network from which content will be downloaded.

Parameters:
inNetwork - The network from which content will be downloaded.

setFetchUri

public void setFetchUri(java.lang.String inUri)
Sets the URI of the content to fetch.

Parameters:
inUri - The URI of the content to fetch.

getContent

public TurboBuffer getContent()
Gets the TurboBuffer that was used by the state engine.

Returns:
The TurboBuffer that was used by the state engine.

run

public abstract void run()
Multi-Threaded entry point. Run in its own thread and use Thread.start().

Specified by:
run in interface java.lang.Runnable