Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.sav
Class InputSource

java.lang.Object
  extended by org.web3d.vrml.sav.InputSource

public class InputSource
extends java.lang.Object

Representation of an input stream of bytes to the reader.

Version:
$Revision: 1.19 $
Author:
Justin Couch

Constructor Summary
InputSource(java.io.File file)
          Create an input source representing the given file.
InputSource(java.lang.String uri)
          Create an input source representation of the given URI string.
InputSource(java.lang.String urlBase, java.io.InputStream is)
          Create an input source from the input stream and the defined base URL.
InputSource(java.lang.String urlBase, java.io.InputStream is, java.lang.String fullUrl)
          Create an input source from the input stream and the defined base URL with the option of providing a known full URL.
InputSource(java.lang.String urlBase, java.io.Reader rdr)
          Create an input source from the reader and the defined base URL.
InputSource(java.lang.String urlBase, java.io.Reader rdr, java.lang.String fullUrl)
          Create an input source from the reader and the defined base URL with with the option of providing a known full URL.
InputSource(java.net.URL url)
          Create an input source representing the given URL.
InputSource(org.ietf.uri.URL url)
          Create an input source representing the given URL.
 
Method Summary
 void close()
          Close the underlying stream used by the source.
 java.lang.String getBaseURL()
          Get the base URL of this stream.
 java.io.InputStream getByteStream()
          Get a stream of raw bytes from the source.
 java.io.Reader getCharacterStream()
          Get a stream of the characters from the source.
 java.lang.String getContentType()
          Get the content type of this source.
 java.lang.String getEncoding()
          Get the encoding, binary or string of the underlying stream.
 java.lang.String getURL()
          Get the fully qualified URL string to the source.
 void setContentType(java.lang.String type)
          Set the content type of this source.
 void setProgressListener(org.ietf.uri.event.ProgressListener listener)
          Set the progress listener.
 void setReadProgressListener(ReadProgressListener listener, int updateSize)
          Set the read progress listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputSource

public InputSource(java.lang.String uri)
Create an input source representation of the given URI string. This may use the given string as a fully qualified URI that needs resolving.

Parameters:
uri - The URI to open.

InputSource

public InputSource(java.io.File file)
Create an input source representing the given file. It does not check for the file existing or a directory on creation. This will be done at the point stream is requested

Parameters:
file - The file to be used as the source

InputSource

public InputSource(java.net.URL url)
Create an input source representing the given URL. It does not open the URL until the stream is requested.

Parameters:
url - The URL to use

InputSource

public InputSource(org.ietf.uri.URL url)
Create an input source representing the given URL. It does not open the URL until the stream is requested.

Parameters:
url - The URL to use

InputSource

public InputSource(java.lang.String urlBase,
                   java.io.InputStream is)
Create an input source from the input stream and the defined base URL. The base is required because it is not possible to determine this from the stream.

Parameters:
urlBase - The name of the base URL for this stream
is - The underlying stream to use

InputSource

public InputSource(java.lang.String urlBase,
                   java.io.InputStream is,
                   java.lang.String fullUrl)
Create an input source from the input stream and the defined base URL with the option of providing a known full URL. The base is required because it is not possible to determine this from the stream. If the real URL is not known, then set a value of null.

Parameters:
urlBase - The name of the base URL for this stream
is - The underlying stream to use
fullUrl - The fully qualified URL string

InputSource

public InputSource(java.lang.String urlBase,
                   java.io.Reader rdr)
Create an input source from the reader and the defined base URL. The base is required because it is not possible to determine this from the stream.

Parameters:
urlBase - The name of the base URL for this stream
rdr - The underlying reader to use

InputSource

public InputSource(java.lang.String urlBase,
                   java.io.Reader rdr,
                   java.lang.String fullUrl)
Create an input source from the reader and the defined base URL with with the option of providing a known full URL. The base is required because it is not possible to determine this from the stream. If the real URL is not known, then set a value of null.

Parameters:
urlBase - The name of the base URL for this stream
rdr - The underlying Reader to use
fullUrl - The fully qualified URL string
Method Detail

getEncoding

public java.lang.String getEncoding()
Get the encoding, binary or string of the underlying stream. The encoding is that of the character stream of the file rather than the VRML encoding statement in the file header eg UTF8. This will not be available until the stream has been opened.

Returns:
The encoding string

getCharacterStream

public java.io.Reader getCharacterStream()
                                  throws java.io.IOException
Get a stream of the characters from the source. The encoding is the same as that given by the getEncoding() method. If the underlying stream has not been opened, then this will force it to open.

Returns:
The reader representing the underlying stream
Throws:
java.io.IOException - An error opening the stream

getByteStream

public java.io.InputStream getByteStream()
                                  throws java.io.IOException
Get a stream of raw bytes from the source. If the underlying stream has not been opened, this will force it to open. The current implementation barfs if the user supplied a raw stream.

Returns:
The stream representing the underlying bytes
Throws:
java.io.IOException - An error opening the stream

getBaseURL

public java.lang.String getBaseURL()
Get the base URL of this stream. This is used by code that may need to resolve other relative URIs in the stream.

Returns:
A string representing the base URL of this connection

getURL

public java.lang.String getURL()
Get the fully qualified URL string to the source. If this is not known, then null is returned and the user should use the base URL.

Returns:
A string representing the full URL of this connection or null

close

public void close()
           throws java.io.IOException
Close the underlying stream used by the source.

Throws:
java.io.IOException - An error closing the stream

setReadProgressListener

public void setReadProgressListener(ReadProgressListener listener,
                                    int updateSize)
Set the read progress listener. If set it will be notified of read progress. This listener is used to expose the stream state to the URI library.

Parameters:
listener - The progress listener.
updateSize - The number of bytes before issuing an update message.

setProgressListener

public void setProgressListener(org.ietf.uri.event.ProgressListener listener)
Set the progress listener. This will notify the listener on changes in download state and progress.

Parameters:
listener - The progress listener.

setContentType

public void setContentType(java.lang.String type)
Set the content type of this source.


getContentType

public java.lang.String getContentType()
Get the content type of this source.


Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium