org.mozilla.pluglet
Interface PlugletStreamListener


public interface PlugletStreamListener

This is a stream listener that provides various methods, such as notification that data is available in the input stream, that the URL has started to load, that it has stopped loading, etc.


Field Summary
static int STREAM_TYPE_AS_FILE
          Indicates file stream type.
static int STREAM_TYPE_AS_FILE_ONLY
          Indicates file-only stream type.
static int STREAM_TYPE_NORMAL
          Indicates normal stream type.
static int STREAM_TYPE_SEEK
          Indicates seek stream type.
 
Method Summary
 int getStreamType()
          Returns the type of stream.
 void onDataAvailable(PlugletStreamInfo streamInfo, java.io.InputStream input, int length)
          This would be called by the browser to indicate that data is available in the input stream.
 void onFileAvailable(PlugletStreamInfo streamInfo, java.lang.String fileName)
          This would be called by the browser to indicate the availability of a local file name for the stream data.
 void onStartBinding(PlugletStreamInfo streamInfo)
          This would be called by the browser to indicate that the URL has started to load.
 void onStopBinding(PlugletStreamInfo streamInfo, int status)
          This would be called by the browser to indicate that the URL has finished loading.
 

Field Detail

STREAM_TYPE_NORMAL

public static final int STREAM_TYPE_NORMAL
Indicates normal stream type. This is a fixed integer value = 1.

In this mode, the browser "pushes" data to the Pluglet as it arrives from the network.


STREAM_TYPE_SEEK

public static final int STREAM_TYPE_SEEK
Indicates seek stream type. This is a fixed integer value = 2.

In this mode, the Pluglet can randomly access ("pull") stream data.


STREAM_TYPE_AS_FILE

public static final int STREAM_TYPE_AS_FILE
Indicates file stream type. This is a fixed integer value = 3.

In this mode, the browser delivers ("pushes") data to the Pluglet as data is saved to a local file. The data is delivered to the Pluglet via a series of write calls.


STREAM_TYPE_AS_FILE_ONLY

public static final int STREAM_TYPE_AS_FILE_ONLY
Indicates file-only stream type. This is a fixed integer value = 4.

In this mode, the browser saves stream data to a local file and when it is done, it sends the full path of the file to the Pluglet (which can then "pull" the data).

Method Detail

onStartBinding

public void onStartBinding(PlugletStreamInfo streamInfo)
This would be called by the browser to indicate that the URL has started to load. This method is called only once -- when the URL starts to load.

Parameters:
plugletInfo - This is the interface (of type PlugletStreamInfo) through which the listener can get specific information about the stream, such as MIME type, URL, date modified, etc.


onDataAvailable

public void onDataAvailable(PlugletStreamInfo streamInfo,
                            java.io.InputStream input,
                            int length)
This would be called by the browser to indicate that data is available in the input stream. This method is called whenever data is written into the input stream by the networking library -- unless the stream type is STREAM_TYPE_AS_FILE_ONLY. In the latter case, onFileAvailable returns the path to the saved stream, and the Pluglet can then "pull" the data.

Parameters:
streamInfo - This is the interface (of type PlugletStreamInfo) through which the listener can get specific information about the stream, such as MIME type, URL, date modified, etc.

input - The input stream containing the data. This stream can be either a blocking or non-blocking stream.

length - The amount of data that was just pushed into the stream.

onFileAvailable

public void onFileAvailable(PlugletStreamInfo streamInfo,
                            java.lang.String fileName)
This would be called by the browser to indicate the availability of a local file name for the stream data.

Parameters:
streamInfo - This is the interface (of type PlugletStreamInfo) through which the listener can get specific information about the stream, such as MIME type, URL, date modified, etc.

fileName - This specifies the full path to the file.

onStopBinding

public void onStopBinding(PlugletStreamInfo streamInfo,
                          int status)
This would be called by the browser to indicate that the URL has finished loading.

Parameters:
streamInfo - This is the interface (of type PlugletStreamInfo) through which the listener can get specific information about the stream, such as MIME type, URL, date modified, etc.

status - This is an int (integer) to indicate the success or failure of the load. 0 (NS_OK) indicates successful loading; any other value indicates failure.

getStreamType

public int getStreamType()
Returns the type of stream.

Parameters:
int - This is an interger representing the stream type:

1 for STREAM_TYPE_NORMAL
2 for STREAM_TYPE_SEEK
3 for STREAM_TYPE_AS_FILE
4 for STREAM_TYPE_AS_FILE_ONLY