Interface WebResource
- All Known Implementing Classes:
WebResource.ByteResource,WebResource.LazyWebResource
public interface WebResource
Represents a customizable resource.
You can use the create methods for simple resources when using ResourceService.
It is assumed that any text based files are encoded in UTF-8.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionbyte[]asBytes()asStream()asString()Return the resource as a UTF-8 String.static WebResourcecreate(byte[] content) Create a new WebResource from byte array.static WebResourcecreate(InputStream in) Creates a new WebResource from an InputStream.static WebResourcecreate(InputStream in, Long lastModified) Creates a new WebResource from an InputStream.static WebResourceCreate a new WebResource from an UTF-8 String.static WebResourcecreate(Supplier<InputStream> in, Long lastModified) Create a lazy WebResource that only reads contents if necessary.
-
Method Details
-
create
Create a new WebResource from byte array.- Parameters:
content- Bytes of the resource.- Returns:
- WebResource.
-
create
Create a new WebResource from an UTF-8 String.- Parameters:
utf8String- String in UTF-8 encoding.- Returns:
- WebResource.
-
create
Creates a new WebResource from an InputStream.- Parameters:
in- InputStream for the resource, closed after inside the method.- Returns:
- WebResource.
- Throws:
IOException- If the stream can not be read.
-
create
Creates a new WebResource from an InputStream.- Parameters:
in- InputStream for the resource, closed after inside the method.lastModified- Epoch millisecond the resource was last modified- Returns:
- WebResource.
- Throws:
IOException- If the stream can not be read.
-
create
Create a lazy WebResource that only reads contents if necessary.- Parameters:
in- Supplier for InputStream, a lazy method that reads input when necessary.lastModified- Last modified date for the resource.- Returns:
- WebResource.
-
asBytes
byte[] asBytes() -
asString
String asString()Return the resource as a UTF-8 String.- Returns:
- The resource in UTF-8.
-
asStream
InputStream asStream() -
getLastModified
-