public class EncodedResource
extends java.lang.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
.
Modifier and Type | Field and Description |
---|---|
private java.nio.charset.Charset |
charset |
private java.lang.String |
encoding |
private Resource |
resource |
Constructor and Description |
---|
EncodedResource(Resource resource)
Create a new EncodedResource for the given Resource,
not specifying a specific encoding.
|
EncodedResource(Resource resource,
java.nio.charset.Charset charset)
Create a new EncodedResource for the given Resource,
using the specified encoding.
|
EncodedResource(Resource resource,
java.lang.String encoding)
Create a new EncodedResource for the given Resource,
using the specified encoding.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
java.nio.charset.Charset |
getCharset()
Return the charset to use for reading from the resource,
or
null if none specified. |
java.lang.String |
getEncoding()
Return the encoding to use for reading from the resource,
or
null if none specified. |
java.io.InputStream |
getInputStream()
Open an
java.io.InputStream for the specified resource,
typically assuming that there is no specific encoding to use. |
java.io.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 <code>Reader</code> is required as opposed to an <code>InputStream</code>,
i.e.
|
java.lang.String |
toString() |
private final Resource resource
private java.lang.String encoding
private java.nio.charset.Charset charset
public EncodedResource(Resource resource)
resource
- the Resource to holdpublic EncodedResource(Resource resource, java.lang.String encoding)
resource
- the Resource to holdencoding
- the encoding to use for reading from the resourcepublic EncodedResource(Resource resource, java.nio.charset.Charset charset)
resource
- the Resource to holdcharset
- the charset to use for reading from the resourcepublic final Resource getResource()
public final java.lang.String getEncoding()
null
if none specified.public final java.nio.charset.Charset getCharset()
null
if none specified.public boolean requiresReader()
getReader()
,
getInputStream()
public java.io.Reader getReader() throws java.io.IOException
java.io.Reader
for the specified resource,
using the specified encoding (if any).java.io.IOException
- if opening the Reader failedrequiresReader()
public java.io.InputStream getInputStream() throws java.io.IOException
java.io.InputStream
for the specified resource,
typically assuming that there is no specific encoding to use.java.io.IOException
- if opening the InputStream failedrequiresReader()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object