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| 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. |
| 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() |
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, @Nullable 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 final Resource getResource()
Resource held by this EncodedResource.@Nullable public final java.lang.String getEncoding()
null if none specified.@Nullable 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 InputStreamSourcenull)java.io.IOException - if opening the InputStream failedrequiresReader(),
getReader()public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object