public class EncodedResource extends Object
Resource
with a specific encoding to be used for reading from the resource.
Used as argument for operations that support to read content with
a specific encoding (usually through a java.io.Reader
.
Reader
Constructor and Description |
---|
EncodedResource(Resource resource)
Create a new EncodedResource for the given Resource,
not specifying a specific encoding.
|
EncodedResource(Resource resource,
Charset charset)
Create a new EncodedResource for the given Resource,
using the specified encoding.
|
EncodedResource(Resource resource,
String encoding)
Create a new EncodedResource for the given Resource,
using the specified encoding.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Charset |
getCharset()
Return the charset to use for reading from the resource,
or
null if none specified. |
String |
getEncoding()
Return the encoding to use for reading from the resource,
or
null if none specified. |
InputStream |
getInputStream()
Open an
java.io.InputStream for the specified resource,
typically assuming that there is no specific encoding to use. |
Reader |
getReader()
Open a
java.io.Reader for the specified resource,
using the specified encoding (if any). |
Resource |
getResource()
Return the Resource held.
|
int |
hashCode() |
boolean |
requiresReader()
Determine whether a
Reader is required as opposed to an InputStream ,
i.e. |
String |
toString() |
public EncodedResource(Resource resource)
resource
- the Resource to holdpublic EncodedResource(Resource resource, String encoding)
resource
- the Resource to holdencoding
- the encoding to use for reading from the resourcepublic final Resource getResource()
public final String getEncoding()
null
if none specified.public final Charset getCharset()
null
if none specified.public boolean requiresReader()
Reader
is required as opposed to an InputStream
,
i.e. whether an encoding or a charset has been specified.getReader()
,
getInputStream()
public Reader getReader() throws IOException
java.io.Reader
for the specified resource,
using the specified encoding (if any).IOException
- if opening the Reader failedrequiresReader()
public InputStream getInputStream() throws IOException
java.io.InputStream
for the specified resource,
typically assuming that there is no specific encoding to use.IOException
- if opening the InputStream failedrequiresReader()