javax.media.protocol
Class URLDataSource

java.lang.Object
  |
  +--javax.media.protocol.DataSource
        |
        +--javax.media.protocol.PullDataSource
              |
              +--javax.media.protocol.URLDataSource
All Implemented Interfaces:
Controls, Controls, Duration

public class URLDataSource
extends PullDataSource

A default data-source created directly from a URL using URLConnection.


Nested Class Summary
(package private)  class URLDataSource.URLSourceStream
          Create a PullSourceStream from a URLConnection.
 
Field Summary
protected  java.net.URLConnection conn
           
protected  boolean connected
           
protected  ContentDescriptor contentType
           
protected  URLDataSource.URLSourceStream[] sources
           
 
Fields inherited from class javax.media.protocol.DataSource
sourceLocator
 
Fields inherited from interface javax.media.Duration
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
Constructor Summary
protected URLDataSource()
          Implemented by subclasses.
  URLDataSource(java.net.URL url)
          Construct a URLDataSource directly from a URL.
 
Method Summary
 void connect()
          Initialize the connection with the source.
 void disconnect()
          Disconnect the source.
 java.lang.String getContentType()
          Return the content type name.
 java.lang.Object getControl(java.lang.String controlName)
          Returns null, because this source doesn't provide any controls.
 java.lang.Object[] getControls()
          Returns an empty array, because this source doesn't provide any controls.
 Time getDuration()
          Returns Duration.DURATION_UNKNOWN.
 PullSourceStream[] getStreams()
          Get the collection of streams that this source manages.
 void start()
          Initiate data-transfer.
 void stop()
          Stops the
 
Methods inherited from class javax.media.protocol.DataSource
getLocator, initCheck, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

protected java.net.URLConnection conn

contentType

protected ContentDescriptor contentType

sources

protected URLDataSource.URLSourceStream[] sources

connected

protected boolean connected
Constructor Detail

URLDataSource

protected URLDataSource()
Implemented by subclasses.


URLDataSource

public URLDataSource(java.net.URL url)
              throws java.io.IOException
Construct a URLDataSource directly from a URL.

Method Detail

getStreams

public PullSourceStream[] getStreams()
Description copied from class: PullDataSource
Get the collection of streams that this source manages. The collection of streams is entirely content dependent. The MIME type of this DataSource provides the only indication of what streams can be available on this connection.

Specified by:
getStreams in class PullDataSource
Returns:
The collection of streams for this source.

connect

public void connect()
             throws java.io.IOException
Initialize the connection with the source.

Specified by:
connect in class DataSource
Throws:
java.io.IOException - Thrown if there are problems setting up the connection.

getContentType

public java.lang.String getContentType()
Return the content type name.

Specified by:
getContentType in class DataSource
Returns:
The content type name.

disconnect

public void disconnect()
Disconnect the source.

Specified by:
disconnect in class DataSource

start

public void start()
           throws java.io.IOException
Description copied from class: DataSource
Initiate data-transfer. The start method must be called before data is available. (You must call connect before calling start.)

Specified by:
start in class DataSource
Throws:
java.io.IOException - Thrown if there are IO problems with the source when start is called.

stop

public void stop()
          throws java.io.IOException
Stops the

Specified by:
stop in class DataSource
java.io.IOException

getDuration

public Time getDuration()
Returns Duration.DURATION_UNKNOWN. The duration is not available from an InputStream.

Returns:
Duration.DURATION_UNKNOWN.

getControls

public java.lang.Object[] getControls()
Returns an empty array, because this source doesn't provide any controls.

Returns:
empty Object array.

getControl

public java.lang.Object getControl(java.lang.String controlName)
Returns null, because this source doesn't provide any controls.

Returns:
the object that implements the control, or null.