Package org.mycore.common.content
Class MCRStringContent
java.lang.Object
org.mycore.common.content.MCRContent
org.mycore.common.content.MCRStringContent
Reads MCRContent from a String's text.
- Author:
- Frank Lützenkichen
-
Field Summary
Fields inherited from class org.mycore.common.content.MCRContent
docType, encoding, lastModified, length, mimeType, name, systemId, usingSession
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Returns the raw contentasString()
Returns content as String, assuming encoding fromMCRContent.getEncoding()
orMCRConstants.DEFAULT_ENCODING
.getETag()
Returns either strong or weak ETag.Returns content as input stream.long
Returns the last modified timelong
length()
Return the length of this content.void
setEncoding
(String encoding) Sets the character encoding to use when transforming the text to a byte stream.Methods inherited from class org.mycore.common.content.MCRContent
asDataURL, asXML, ensureXML, getContentInputStream, getDataURLEncoding, getDocType, getEncoding, getInputSource, getMimeType, getName, getReadableByteChannel, getReusableCopy, getSafeEncoding, getSimpleWeakETag, getSource, getSystemId, isReusable, isUsingSession, sendTo, sendTo, sendTo, sendTo, setDocType, setLastModified, setMimeType, setName, setUsingSession
-
Constructor Details
-
MCRStringContent
Reads content from the given string,
-
-
Method Details
-
setEncoding
Sets the character encoding to use when transforming the text to a byte stream. By default, this isMCRConstants.DEFAULT_ENCODING
.- Overrides:
setEncoding
in classMCRContent
- Throws:
UnsupportedEncodingException
-
getInputStream
Description copied from class:MCRContent
Returns content as input stream. Be sure to close this stream properly!- Specified by:
getInputStream
in classMCRContent
- Returns:
- input stream to read content from
- Throws:
IOException
-
asByteArray
Description copied from class:MCRContent
Returns the raw content- Overrides:
asByteArray
in classMCRContent
- Returns:
- the content
- Throws:
UnsupportedEncodingException
-
asString
Description copied from class:MCRContent
Returns content as String, assuming encoding fromMCRContent.getEncoding()
orMCRConstants.DEFAULT_ENCODING
.- Overrides:
asString
in classMCRContent
- Returns:
- content as String
-
length
Description copied from class:MCRContent
Return the length of this content.- Overrides:
length
in classMCRContent
- Returns:
- -1 if length is unknown
- Throws:
IOException
-
lastModified
Description copied from class:MCRContent
Returns the last modified time- Overrides:
lastModified
in classMCRContent
- Returns:
- -1 if last modified time is unknown
- Throws:
IOException
-
getETag
Description copied from class:MCRContent
Returns either strong or weak ETag.- Overrides:
getETag
in classMCRContent
- Returns:
- null, if no ETag could be generated
- Throws:
IOException
-