Package com.metreeca.xml.formats
Class XMLFormat
XML message format.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default MIME type for XML message bodies ("application/xml").static final Pattern
A pattern matching XML-based MIME types, for instanceapplication/rss+xml
.Fields inherited from class com.metreeca.rest.Format
MIMEDefault
-
Method Summary
Modifier and TypeMethodDescriptionDecodes the XMLmessage
body from the input stream supplied by themessage
InputFormat
body, if one is available and themessage
Content-Type
header is matched byMIMEPattern
, taking into account themessage
charset<M extends Message<M>>
MConfiguresmessage
Content-Type
header to "application/xml", unless already defined, and encodes the XMLvalue
into the output stream accepted by themessage
OutputFormat
body, taking into account themessage
charsetmime()
static XMLFormat
xml()
Creates an XML message format.static Either<TransformerException,
Document> xml
(InputStream input) Parses a XML document.static Either<TransformerException,
Document> xml
(InputStream input, String base) Parses a XML document.static Either<TransformerException,
Document> Parses a XML document.static XMLFormat
Creates an XML message format using a custom SAX parser.
-
Field Details
-
MIME
The default MIME type for XML message bodies ("application/xml").- See Also:
-
MIMEPattern
A pattern matching XML-based MIME types, for instanceapplication/rss+xml
.
-
-
Method Details
-
xml
Creates an XML message format.- Returns:
- a new XML message format
-
xml
Creates an XML message format using a custom SAX parser.- Parameters:
parser
- the custom SAX parser- Returns:
- a new XML message format a custom SAX
parser
- Throws:
NullPointerException
- ifparser
is null
-
xml
Parses a XML document.- Parameters:
input
- the input stream the XML document is to be parsed from- Returns:
- either a parsing exception or the XML document parsed from
input
- Throws:
NullPointerException
- ifinput
is null
-
xml
Parses a XML document.- Parameters:
input
- the input stream the XML document is to be parsed frombase
- the possibly null base URL for the XML document to be parsed- Returns:
- either a parsing exception or the XML document parsed from
input
- Throws:
NullPointerException
- ifinput
is null
-
xml
Parses a XML document.- Parameters:
source
- the source the XML document is to be parsed from- Returns:
- either a parsing exception or the XML document parsed from
source
- Throws:
NullPointerException
- ifsource
is null
-
mime
- Overrides:
mime
in classFormat<Document>
- Returns:
- the default MIME type for XML messages ("application/xml")
-
decode
Decodes the XMLmessage
body from the input stream supplied by themessage
InputFormat
body, if one is available and themessage
Content-Type
header is matched byMIMEPattern
, taking into account themessage
charset -
encode
Configuresmessage
Content-Type
header to "application/xml", unless already defined, and encodes the XMLvalue
into the output stream accepted by themessage
OutputFormat
body, taking into account themessage
charset
-