Package org.web3d.vrml.sav
Class InputSource
java.lang.Object
org.web3d.vrml.sav.InputSource
Representation of an input stream of bytes to the reader.
- Version:
- $Revision: 1.19 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionInputSource
(File file) Create an input source representing the given file.InputSource
(String uri) Create an input source representation of the given URI string.InputSource
(String urlBase, InputStream is) Create an input source from the input stream and the defined base URL.InputSource
(String urlBase, InputStream is, 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
(String urlBase, Reader rdr) Create an input source from the reader and the defined base URL.InputSource
(String urlBase, Reader rdr, 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
(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
Modifier and TypeMethodDescriptionvoid
close()
Close the underlying stream used by the source.Get the base URL of this stream.Get a stream of raw bytes from the source.Get a stream of the characters from the source.Get the content type of this source.Get the encoding, binary or string of the underlying stream.getURL()
Get the fully qualified URL string to the source.void
setContentType
(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.
-
Constructor Details
-
InputSource
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- Throws:
MalformedURLException
- if uri can not be resolved as a URL complete with proper scheme
-
InputSource
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- Throws:
MalformedURLException
- if the file uri can not be resolved as a URL complete with proper scheme
-
InputSource
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 org.ietf.uri.URL to use
-
InputSource
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 streamis
- The underlying stream to use
-
InputSource
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 streamis
- The underlying stream to usefullUrl
- The fully qualified URL string
-
InputSource
-
InputSource
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 streamrdr
- The underlying Reader to usefullUrl
- The fully qualified URL string
-
-
Method Details
-
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
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:
IOException
- An error opening the stream
-
getByteStream
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:
IOException
- An error opening the stream
-
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
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
Close the underlying stream used by the source.- Throws:
IOException
- An error closing the stream
-
setReadProgressListener
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
Set the content type of this source.- Parameters:
type
- the type to set
-
getContentType
-