public class EncodedResource extends java.lang.Object implements InputStreamSource
Resource
descriptor with a specific encoding
or Charset
to be used for reading from the resource.
Used as an argument for operations that support reading content with
a specific encoding, typically via a java.io.Reader
.
InputStreamSource.getInputStream()
,
Reader
,
Charset
Modifier and Type | Field and Description |
---|---|
private java.nio.charset.Charset |
charset |
private java.lang.String |
encoding |
private Resource |
resource |
Modifier | Constructor and Description |
---|---|
|
EncodedResource(Resource resource)
Create a new
EncodedResource for the given Resource ,
not specifying an explicit encoding or Charset . |
|
EncodedResource(Resource resource,
java.nio.charset.Charset charset)
Create a new
EncodedResource for the given Resource ,
using the specified Charset . |
|
EncodedResource(Resource resource,
java.lang.String encoding)
Create a new
EncodedResource for the given Resource ,
using the specified encoding . |
private |
EncodedResource(Resource resource,
java.lang.String encoding,
java.nio.charset.Charset charset) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
java.nio.charset.Charset |
getCharset()
|
java.lang.String |
getEncoding()
Return the encoding to use for reading from the resource,
or
null if none specified. |
java.io.InputStream |
getInputStream()
|
java.io.Reader |
getReader()
|
Resource |
getResource()
Return the
Resource held by this EncodedResource . |
int |
hashCode() |
boolean |
requiresReader()
Determine whether a
Reader is required as opposed to an InputStream ,
i.e. |
java.lang.String |
toString() |
private final Resource resource
private final java.lang.String encoding
private final java.nio.charset.Charset charset
public EncodedResource(Resource resource)
EncodedResource
for the given Resource
,
not specifying an explicit encoding or Charset
.resource
- the Resource
to hold (never null
)public EncodedResource(Resource resource, java.lang.String encoding)
EncodedResource
for the given Resource
,
using the specified encoding
.resource
- the Resource
to hold (never null
)encoding
- the encoding to use for reading from the resourcepublic EncodedResource(Resource resource, java.nio.charset.Charset charset)
EncodedResource
for the given Resource
,
using the specified Charset
.resource
- the Resource
to hold (never null
)charset
- the Charset
to use for reading from the resourceprivate EncodedResource(Resource resource, java.lang.String encoding, java.nio.charset.Charset charset)
public final Resource getResource()
Resource
held by this EncodedResource
.public final java.lang.String getEncoding()
null
if none specified.public final java.nio.charset.Charset getCharset()
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 java.io.Reader getReader() throws java.io.IOException
java.io.IOException
- if opening the Reader failedrequiresReader()
,
getInputStream()
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in interface InputStreamSource
null
)java.io.IOException
- if opening the InputStream failedrequiresReader()
,
getReader()
public boolean equals(java.lang.Object other)
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