Build 1.0_r1(from source)

android.webkit
Class StreamLoader

java.lang.Object
  extended by android.os.Handler
      extended by android.webkit.StreamLoader
Direct Known Subclasses:
CacheLoader, ContentLoader, DataLoader, FileLoader

abstract class StreamLoader
extends Handler

This abstract class is used for all content loaders that rely on streaming content into the rendering engine loading framework. The class implements a state machine to load the content into the frame in a similar manor to the way content arrives from the network. The class uses messages to move from one state to the next, which enables async. loading of the streamed content. Classes that inherit from this class must implement two methods, the first method is used to setup the InputStream and notify the loading framework if it can load it's content. The other method allows the derived class to add additional HTTP headers to the response. By default, content loaded with a StreamLoader is marked with a HTTP header that indicates the content should not be cached.


Field Summary
protected  long mContentLength
           
protected  InputStream mDataStream
           
protected  LoadListener mHandler
           
static String NO_STORE
           
 
Constructor Summary
StreamLoader(LoadListener loadlistener)
          Constructor.
 
Method Summary
protected abstract  void buildHeaders(Headers headers)
          This method is called when the headers are about to be sent to the load framework.
 void handleMessage(Message msg)
          Subclasses must implement this to receive messages.
 void load()
          Calling this method starts the load of the content for this StreamLoader.
protected abstract  boolean setupStreamAndSendStatus()
          This method is called when the derived class should setup mDataStream, and call mHandler.status() to indicate that the load can occur.
 
Methods inherited from class android.os.Handler
dispatchMessage, dump, getLooper, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_STORE

public static final String NO_STORE
See Also:
Constant Field Values

mHandler

protected LoadListener mHandler

mDataStream

protected InputStream mDataStream

mContentLength

protected long mContentLength
Constructor Detail

StreamLoader

StreamLoader(LoadListener loadlistener)
Constructor. Although this class calls the LoadListener, it only calls the EventHandler Interface methods. LoadListener concrete class is used to avoid the penality of calling an interface.

Parameters:
loadlistener - The LoadListener to call with the data.
Method Detail

setupStreamAndSendStatus

protected abstract boolean setupStreamAndSendStatus()
This method is called when the derived class should setup mDataStream, and call mHandler.status() to indicate that the load can occur. If it fails to setup, it should still call status() with the error code.

Returns:
true if stream was successfully setup

buildHeaders

protected abstract void buildHeaders(Headers headers)
This method is called when the headers are about to be sent to the load framework. The derived class has the opportunity to add addition headers.

Parameters:
headers - Map of HTTP headers that will be sent to the loader.

load

public void load()
Calling this method starts the load of the content for this StreamLoader. This method simply posts a message to send the status and returns immediately.


handleMessage

public void handleMessage(Message msg)
Description copied from class: Handler
Subclasses must implement this to receive messages.

Overrides:
handleMessage in class Handler

Build 1.0_r1(from source)

Please submit a feedback, bug or feature