public interface DataSource
FileDataSource
) is not enough, you can design
your own data provider object and give it to the server with the
setDataSource()
method.Modifier and Type | Method and Description |
---|---|
long |
getContentLength()
Returns the length of data to deliver in the HTTP response entity, if known.
|
long |
getContentSize()
Returns the total length of the resource content, if known.
|
String |
getContentType()
Returns the content type of the resource, if known.
|
InputStream |
getInputStream()
Returns a content stream of the resource.
|
long |
getOffset()
Returns the offset in the resource flow.
|
String |
getUriString()
Returns the URI of the data source.
|
boolean |
isExisting()
Tests whether the resource exists.
|
boolean |
isPartial()
Tells whether the content to be delivered will be partial.
|
boolean |
isReadable()
Tests whether the resource can be read.
|
void |
setCipher(Cipher cipher)
Sets the
Cipher to use if the stream has to be decrypted. |
void |
setCipherFactory(CipherFactory cipherFactory)
Sets the factory instance, able to deliver ciphers when needed.
|
void |
setSource(URI uri,
long offset)
Sets the properties of the data source.
|
void setCipher(Cipher cipher)
Cipher
to use if the stream has to be decrypted.
The information may also be set through HttpServer.setCipher(Cipher)
.cipher
- The cipher needed to decrypt the stream.void setCipherFactory(CipherFactory cipherFactory)
HttpServer.setCipherFactory(CipherFactory)
.cipherFactory
- The factory to deliver ciphers on demand.void setSource(URI uri, long offset)
uri
- The URI as provided in the HTTP request line.offset
- The offset provided in a Range
request header, or 0 by default.String getUriString()
null
if called before setSource()
by mistake.boolean isExisting()
true
if and only if the resource really exists.boolean isReadable()
true
if and only if the resource can be accessed for reading.InputStream getInputStream() throws IOException
IOException
- If the stream cannot be created or skipped, or if some other I/O error occurs.boolean isPartial()
offset
is set.true
if the content to deliver is only a part of the full resource.long getContentSize()
Content-Range
header.long getOffset()
long getContentLength()
getInputStream()
method.String getContentType()
null
if the type is unknown.