com.monkeycoder.monkeynetwork
Class MonkeyNetwork

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

public class MonkeyNetwork
extends java.util.Observable
implements java.util.Observer

This is the simplified access point for the MonkeyNetwork system.

Author:
David Stephens

Constructor Summary
MonkeyNetwork()
          This is the simplified access point for the MonkeyNetwork system.
 
Method Summary
 java.io.InputStream blockFetch(java.lang.String inUrl)
          Simplified blocking call to fetch content from the network.
 void fetch(java.lang.String inUrl)
          Standard non-blocking call to fetch content from the network.
 void update(java.util.Observable inObservable, java.lang.Object inArg)
          Used by Network objects to pass messages to this class.
 
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

MonkeyNetwork

public MonkeyNetwork()
This is the simplified access point for the MonkeyNetwork system.

Method Detail

blockFetch

public java.io.InputStream blockFetch(java.lang.String inUrl)
                               throws java.io.IOException,
                                      MonkeyException
Simplified blocking call to fetch content from the network. This method provides fully self-contained network access. It blocks until the content is downloaded completely and returns an InputStream as access to the downloaded content.

Parameters:
inUrl - The URL of the content to fetch.
Returns:
InputStream to the fetched content or null if the content failed to download.
Throws:
java.io.IOException - When underlying code produces it.
MonkeyException - When underlying code produces it.

fetch

public void fetch(java.lang.String inUrl)
           throws java.io.IOException,
                  MonkeyException
Standard non-blocking call to fetch content from the network. This method queues up subsequent requests and processes them one at a time. Each completed download is indicated by the receipt of an UpdateMessage that contains an InputStream to the downloaded content as its data. If the download failed, the UpdateMessage will show that by its type.

Parameters:
inUrl - The URL of the content to fetch.
Throws:
java.io.IOException - When underlying code produces it.
MonkeyException - When underlying code produces it.
See Also:
UpdateMessage

update

public void update(java.util.Observable inObservable,
                   java.lang.Object inArg)
Used by Network objects to pass messages to this class.

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