javax.media.protocol
Class InputSourceStream

java.lang.Object
  |
  +--javax.media.protocol.InputSourceStream
All Implemented Interfaces:
Controls, Controls, PullSourceStream, SourceStream
Direct Known Subclasses:
URLDataSource.URLSourceStream

public class InputSourceStream
extends java.lang.Object
implements PullSourceStream

Build a source stream out of an input stream.

Version:
1.3, 02/08/21.
See Also:
DataSource, SourceStream, InputStream

Field Summary
(package private)  ContentDescriptor contentType
           
protected  boolean eosReached
           
protected  java.io.InputStream stream
           
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
InputSourceStream(java.io.InputStream s, ContentDescriptor type)
          Construct an InputSourceStream from an input stream.
 
Method Summary
 void close()
          Turn the stream off.
 boolean endOfStream()
          Return if the end of stream has been reached.
 ContentDescriptor getContentDescriptor()
          Get the content type for this stream.
 long getContentLength()
          Obtain the content length
 java.lang.Object getControl(java.lang.String controlName)
          Returns null because no controls are implemented.
 java.lang.Object[] getControls()
          Returns an zero length array because no controls are supported.
 int read(byte[] buffer, int offset, int length)
          Read a buffer of data.
 boolean willReadBlock()
          Query if the next read will block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stream

protected java.io.InputStream stream

eosReached

protected boolean eosReached

contentType

ContentDescriptor contentType
Constructor Detail

InputSourceStream

public InputSourceStream(java.io.InputStream s,
                         ContentDescriptor type)
Construct an InputSourceStream from an input stream.

Parameters:
s - The input stream to build the source stream from.
type - The content-type of the source stream.
Method Detail

getContentDescriptor

public ContentDescriptor getContentDescriptor()
Get the content type for this stream.

Specified by:
getContentDescriptor in interface SourceStream
Returns:
content descriptor for the stream.

getContentLength

public long getContentLength()
Obtain the content length

Specified by:
getContentLength in interface SourceStream
Returns:
content length for this stream.

willReadBlock

public boolean willReadBlock()
Query if the next read will block.

Specified by:
willReadBlock in interface PullSourceStream
Returns:
true if a read will block.

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Read a buffer of data.

Specified by:
read in interface PullSourceStream
Parameters:
buffer - The buffer to read data into.
offset - The offset into the buffer for reading.
length - The number of bytes to read.
Returns:
The number of bytes read or -1 indicating end-of-stream.
Throws:
java.io.IOException - Thrown if an error occurs while reading.

close

public void close()
           throws java.io.IOException
Turn the stream off.

Throws:
java.io.IOException - Thrown if there is a problem closing the stream.

endOfStream

public boolean endOfStream()
Return if the end of stream has been reached.

Specified by:
endOfStream in interface SourceStream
Returns:
true if the end of the stream has been reached.

getControls

public java.lang.Object[] getControls()
Returns an zero length array because no controls are supported.

Specified by:
getControls in interface Controls
Returns:
a zero length Object array.

getControl

public java.lang.Object getControl(java.lang.String controlName)
Returns null because no controls are implemented.

Specified by:
getControl in interface Controls
Returns:
null.