Package org.mycore.common.content
Class MCRXMLContent
java.lang.Object
org.mycore.common.content.MCRContent
org.mycore.common.content.MCRXMLContent
- Direct Known Subclasses:
MCRDOMContent
,MCRJAXBContent
,MCRJDOMContent
,MCRSAXContent
Reads MCRContent from an XML document.
Provides functionality to output XML using different formatters.
- Author:
- Frank Lützenkichen
-
Field Summary
Modifier and TypeFieldDescriptionprotected static Format
The default format used when outputting XML as a byte stream.protected Format
The default format used when outputting this XML as a byte streamFields inherited from class org.mycore.common.content.MCRContent
docType, encoding, lastModified, length, mimeType, name, systemId, usingSession
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionEnsures that content is XML.getETag()
Returns either strong or weak ETag.Returns content as input stream.long
length()
Return the length of this content.void
setEncoding
(String encoding) void
Sets the format used when outputting XML as a byte stream.Methods inherited from class org.mycore.common.content.MCRContent
asByteArray, asDataURL, asString, asXML, getContentInputStream, getDataURLEncoding, getDocType, getEncoding, getInputSource, getName, getReadableByteChannel, getReusableCopy, getSafeEncoding, getSimpleWeakETag, getSource, getSystemId, isReusable, isUsingSession, lastModified, sendTo, sendTo, sendTo, sendTo, setDocType, setLastModified, setMimeType, setName, setUsingSession
-
Field Details
-
defaultFormat
The default format used when outputting XML as a byte stream. By default, content is outputted usingMCRConstants.DEFAULT_ENCODING
. If MCR.IFS2.PrettyXML=true, a pretty format with indentation is used. -
format
The default format used when outputting this XML as a byte stream
-
-
Constructor Details
-
MCRXMLContent
public MCRXMLContent()
-
-
Method Details
-
setFormat
Sets the format used when outputting XML as a byte stream. By default, content is outputted usingMCRConstants.DEFAULT_ENCODING
. If MCR.IFS2.PrettyXML=true, a pretty format with indentation is used. -
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
-
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
-
getMimeType
- Overrides:
getMimeType
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
-
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
-
setEncoding
- Overrides:
setEncoding
in classMCRContent
- Throws:
UnsupportedEncodingException
-