com.monkeycoder.monkeynetwork
Class HttpNetwork

java.lang.Object
  extended by java.util.Observable
      extended by com.monkeycoder.monkeynetwork.Network
          extended by com.monkeycoder.monkeynetwork.HttpNetwork
All Implemented Interfaces:
java.util.Observer

public class HttpNetwork
extends Network

This class handles an HTTP Network.

Author:
David Stephens

Field Summary
 
Fields inherited from class com.monkeycoder.monkeynetwork.Network
conAddr, inStream, outStream, sock, stateEngine
 
Constructor Summary
HttpNetwork()
          Creates an HttpNetwork.
 
Method Summary
 void fetch(java.lang.String inUri)
          Fetches web content via the transport medium specified by this network.
 int getNetworkProtocol()
          Get the protocol of this network object.
 void update(java.util.Observable inObservable, java.lang.Object inArg)
          Used by the network state engine to pass messages to this class.
 
Methods inherited from class com.monkeycoder.monkeynetwork.Network
connect, disconnect, getContent, getEndpointHost, getEndpointPort, getInputStream, getOutputStream, isConnected, setEndpoint
 
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
 

Constructor Detail

HttpNetwork

public HttpNetwork()
Creates an HttpNetwork.

Method Detail

getNetworkProtocol

public int getNetworkProtocol()
Get the protocol of this network object.

Specified by:
getNetworkProtocol in class Network
Returns:
NetworkProtocol.PROTOCOL_HTTP
See Also:
NetworkProtocol

fetch

public void fetch(java.lang.String inUri)
           throws java.io.IOException,
                  MonkeyException
Fetches web content via the transport medium specified by this network. This method does not return the content directly and returns immediately after setting up the requested transfer. Once the transfer is complete (or fails) an UpdateMessage will be issued to observers.

Specified by:
fetch in class Network
Parameters:
inUri - The content being requested. This is a partial URI based on the established connection.
Throws:
java.io.IOException - When thrown by underlying network code.
MonkeyException - If the network is not yet connected.
See Also:
UpdateMessage

update

public void update(java.util.Observable inObservable,
                   java.lang.Object inArg)
Used by the network state engine to pass messages to this class. This class is a pure relay to observers of the network.

Specified by:
update in interface java.util.Observer
Specified by:
update in class Network
Parameters:
inObservable - The observable object.
inArg - The UpdateMessage passed to the notifyObservers method.
See Also:
UpdateMessage