Class EncodedResource
java.lang.Object
org.springframework.core.io.support.EncodedResource
- All Implemented Interfaces:
InputStreamSource
Holder that combines a
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.
- Since:
- 1.2.6
- Author:
- Juergen Hoeller, Sam Brannen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEncodedResource(Resource resource) Create a newEncodedResourcefor the givenResource, not specifying an explicit encoding orCharset.EncodedResource(Resource resource, String encoding) Create a newEncodedResourcefor the givenResource, using the specifiedencoding.EncodedResource(Resource resource, Charset charset) Create a newEncodedResourcefor the givenResource, using the specifiedCharset. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal Charsetfinal StringReturn the encoding to use for reading from the resource, ornullif none specified.final ResourceReturn theResourceheld by thisEncodedResource.inthashCode()booleanDetermine whether aReaderis required as opposed to anInputStream, i.e.toString()
-
Constructor Details
-
EncodedResource
Create a newEncodedResourcefor the givenResource, not specifying an explicit encoding orCharset.- Parameters:
resource- theResourceto hold (nevernull)
-
EncodedResource
Create a newEncodedResourcefor the givenResource, using the specifiedencoding.- Parameters:
resource- theResourceto hold (nevernull)encoding- the encoding to use for reading from the resource
-
EncodedResource
Create a newEncodedResourcefor the givenResource, using the specifiedCharset.- Parameters:
resource- theResourceto hold (nevernull)charset- theCharsetto use for reading from the resource
-
-
Method Details
-
getResource
Return theResourceheld by thisEncodedResource. -
getEncoding
Return the encoding to use for reading from the resource, ornullif none specified. -
getCharset
-
requiresReader
public boolean requiresReader()Determine whether aReaderis required as opposed to anInputStream, i.e. whether an encoding or aCharsethas been specified.- See Also:
-
getReader
- Throws:
IOException- if opening the Reader failed- See Also:
-
getInputStream
- Specified by:
getInputStreamin interfaceInputStreamSource- Returns:
- the input stream for the underlying resource (must not be
null) - Throws:
IOException- if opening the InputStream failed- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-