Interface Resource
public interface Resource
A
Resource represents any content that can be served through the ResourceHandler.-
Method Summary
Modifier and TypeMethodDescriptionlongReturns the timestamp when the resource has been last modified (expressed inTimeUnit.MILLISECONDS).getSize()Returns the size of the resource, when known.getType()Returns the media type of this resource.booleanhasChangedSince(long sinceTime) Returnstrueif the resource has changed since the given timestamp (expressed in ms).open()Returns a newInputStreamused to read resource's content.
-
Method Details
-
open
Returns a newInputStreamused to read resource's content. Note that this is the responsibility of the caller to close the stream.- Returns:
- a new
InputStream - Throws:
IOException- if the stream cannot be opened
-
getType
String getType()Returns the media type of this resource.- Returns:
- the media type of this resource.
-
getLastModified
long getLastModified()Returns the timestamp when the resource has been last modified (expressed inTimeUnit.MILLISECONDS).- Returns:
- the timestamp when the resource has been last modified (ms)
-
hasChangedSince
boolean hasChangedSince(long sinceTime) Returnstrueif the resource has changed since the given timestamp (expressed in ms).- Parameters:
sinceTime- timestamp to compare with this resource's last modified timestamp.- Returns:
trueif the resource has changed since the given timestamp (expressed in ms).
-
getSize
Returns the size of the resource, when known.- Returns:
- The size of the resource, when known, otherwise an empty optional
-