Package org.mycore.common.content
Class MCRWrappedContent
java.lang.Object
org.mycore.common.content.MCRContent
org.mycore.common.content.MCRWrappedContent
- Direct Known Subclasses:
MCRSourceContent
- Author:
- Thomas Scheffler (yagee)
-
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
.asXML()
Parses content, assuming it is XML, and returns the parsed document.Ensures that content is XML.Returns content as content input stream, which provides MD5 functionality.Return the document type of the content, assuming content is XMLgetETag()
Returns either strong or weak ETag.Returns content as SAX input source.Returns content as input stream.getName()
Returns an readable bytechannel to this content or null if one is not available.Returns a reusable copy of this content, that is an instance (may be the same instance) thats content can be read more than once without consuming the stream.Return the content as SourceReturns the systemID of the current contentboolean
If true, content can be read more than once by calling getInputStream() and similar methods.boolean
Tells if this content may contain data from the current MCRSession.long
Returns the last modified timelong
length()
Return the length of this content.void
Sends content to the given local filevoid
sendTo
(OutputStream out) Sends content to the given OutputStream.void
sendTo
(OutputStream out, boolean close) Sends content to the given OutputStream.void
sendTo
(Path target, CopyOption... options) Sends content to the given path.protected void
setBaseContent
(MCRContent baseContent) void
setDocType
(String docType) Overwrites DocType detection.void
setLastModified
(long lastModified) void
setMimeType
(String mimeType) void
void
setUsingSession
(boolean usingSession) Methods inherited from class org.mycore.common.content.MCRContent
asDataURL, getDataURLEncoding, getEncoding, getSafeEncoding, getSimpleWeakETag, setEncoding
-
Constructor Details
-
MCRWrappedContent
public MCRWrappedContent()
-
-
Method Details
-
getBaseContent
-
setBaseContent
-
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
-
getSystemId
Description copied from class:MCRContent
Returns the systemID of the current content- Overrides:
getSystemId
in classMCRContent
-
getContentInputStream
Description copied from class:MCRContent
Returns content as content input stream, which provides MD5 functionality. Be sure to close this stream properly!- Overrides:
getContentInputStream
in classMCRContent
- Returns:
- the content input stream
- Throws:
IOException
-
getSource
Description copied from class:MCRContent
Return the content as Source- Overrides:
getSource
in classMCRContent
- Returns:
- content as Source
- Throws:
IOException
-
sendTo
Description copied from class:MCRContent
Sends content to the given OutputStream. The OutputStream is NOT automatically closed afterwards.- Overrides:
sendTo
in classMCRContent
- Parameters:
out
- the OutputStream to write the content to- Throws:
IOException
-
sendTo
Description copied from class:MCRContent
Sends content to the given OutputStream.- Overrides:
sendTo
in classMCRContent
- Parameters:
out
- the OutputStream to write the content toclose
- if true, close OutputStream afterwards- Throws:
IOException
-
sendTo
Description copied from class:MCRContent
Sends content to the given path.- Overrides:
sendTo
in classMCRContent
- Parameters:
target
- target path to write content tooptions
- seeFiles.copy(InputStream, Path, CopyOption...)
} for help on copy options- Throws:
IOException
-
getInputSource
Description copied from class:MCRContent
Returns content as SAX input source.- Overrides:
getInputSource
in classMCRContent
- Returns:
- input source to read content from
- Throws:
IOException
-
sendTo
Description copied from class:MCRContent
Sends content to the given local file- Overrides:
sendTo
in classMCRContent
- Parameters:
target
- the file to write the content to- Throws:
IOException
-
asByteArray
Description copied from class:MCRContent
Returns the raw content- Overrides:
asByteArray
in classMCRContent
- Returns:
- the content
- Throws:
IOException
-
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
- Throws:
IOException
-
asXML
Description copied from class:MCRContent
Parses content, assuming it is XML, and returns the parsed document.- Overrides:
asXML
in classMCRContent
- Returns:
- the XML document parsed from content
- Throws:
JDOMException
IOException
SAXException
-
ensureXML
Description copied from class:MCRContent
Ensures that content is XML. The content is parsed as if asXML() is called. When content is XML, an MCRContent instance is returned that guarantees that. When XML can not be parsed, an exception is thrown.- Overrides:
ensureXML
in classMCRContent
- Throws:
IOException
JDOMException
SAXException
-
getDocType
Description copied from class:MCRContent
Return the document type of the content, assuming content is XML- Overrides:
getDocType
in classMCRContent
- Returns:
- document type as String
- Throws:
IOException
-
isReusable
public boolean isReusable()Description copied from class:MCRContent
If true, content can be read more than once by calling getInputStream() and similar methods. If false, content may be consumed when it is read more than once. Most subclasses provide reusable content.- Overrides:
isReusable
in classMCRContent
-
getReusableCopy
Description copied from class:MCRContent
Returns a reusable copy of this content, that is an instance (may be the same instance) thats content can be read more than once without consuming the stream.- Overrides:
getReusableCopy
in classMCRContent
- Throws:
IOException
-
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
-
setLastModified
public void setLastModified(long lastModified) - Overrides:
setLastModified
in classMCRContent
-
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
-
getReadableByteChannel
Description copied from class:MCRContent
Returns an readable bytechannel to this content or null if one is not available.- Overrides:
getReadableByteChannel
in classMCRContent
- Throws:
IOException
-
setDocType
Description copied from class:MCRContent
Overwrites DocType detection.- Overrides:
setDocType
in classMCRContent
- See Also:
-
getMimeType
- Overrides:
getMimeType
in classMCRContent
- Throws:
IOException
-
setMimeType
- Overrides:
setMimeType
in classMCRContent
-
getName
- Overrides:
getName
in classMCRContent
-
setName
- Overrides:
setName
in classMCRContent
-
isUsingSession
public boolean isUsingSession()Description copied from class:MCRContent
Tells if this content may contain data from the current MCRSession. Use this information to alter cache behavior.- Overrides:
isUsingSession
in classMCRContent
- Returns:
- true if it MAY contain session data
-
setUsingSession
public void setUsingSession(boolean usingSession) - Overrides:
setUsingSession
in classMCRContent
-