public abstract class XMLMessage extends java.lang.Object implements AbstractMessage
canProcess()
methods.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
docname
Name of the root element.
|
protected org.jdom.Document |
document
XML document to be processed.
|
protected java.net.URL |
dtd
Name of the corresponding XML document type definition (DTD), set by sub class.
|
protected java.lang.String |
encoding
Original encoding of the document.
|
protected org.jdom.output.Format |
format
Name of the root element.
|
Constructor and Description |
---|
XMLMessage()
Constructor method for i18n purposes only.
|
XMLMessage(java.net.URL dtd,
java.lang.String docname)
Constructs an instance based on a given DTD.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canProcess(java.io.InputStream istream)
Checks whether the given input stream can be read/written by this message.
|
org.jdom.Attribute |
getAttribute(java.lang.String expression)
Provides an XML attribute on basis of an XPath expression.
|
java.lang.String |
getAttributeValue(java.lang.String expression)
Provides an XML attribute value on basis of an XPath expression.
|
java.lang.String |
getContents(java.lang.String encoding)
Provides the formatted XML document for debugging.
|
org.jdom.Document |
getDocument()
Provides the internally used XML document.
|
java.net.URL |
getDTD()
Provides the URL to load the associated DTD for validation purposes.
|
org.jdom.Element |
getElement(java.lang.String expression)
Provides an XML element on basis of an XPath expression.
|
java.util.List |
getElements(java.lang.String expression)
Provides a list of XML elements on basis of an XPath expression.
|
java.lang.String |
getElementValue(java.lang.String expression)
Provides an XML element value on basis of an XPath expression.
|
java.lang.String |
getEncoding()
Provides the document encoding.
|
int |
getIntFunctionResult(java.lang.String expression)
Provides an XML function value on basis of an XPath expression.
|
boolean |
isArmed()
Has the message successfully been loaded with payload?
|
boolean |
isValid()
Determines whether the message contents are valid and can be used.
|
void |
printDocument(java.lang.String encoding)
Prints the formatted XML document via
System.out . |
boolean |
read(byte[] data)
Reads the message contents from the given binary data array (convenience).
|
boolean |
read(java.io.InputStream istream)
Reads the message contents from the given input stream.
|
void |
setEncoding(java.lang.String encoding)
Sets the document encoding.
|
void |
setFormat(org.jdom.output.Format format)
Overrides the default format
Format.getPrettyFormat() . |
boolean |
write(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Generates response message data with the given servlet response.
|
boolean |
write(java.io.OutputStream ostream,
java.lang.String encoding)
Generates response message data with the given output stream.
|
protected org.jdom.Document document
protected java.net.URL dtd
protected java.lang.String docname
protected org.jdom.output.Format format
protected java.lang.String encoding
public XMLMessage() throws java.lang.InstantiationException
I18NExtractor
).
java.lang.InstantiationException
- Error indicationpublic XMLMessage(java.net.URL dtd, java.lang.String docname)
dtd
- The document type definition, requireddocname
- Name of the root elementjava.lang.NullPointerException
- If parameter is invalidpublic boolean canProcess(java.io.InputStream istream)
BufferedInputStream
and mark the position before
this method is called. Reset the stream when the method has done its job to allow other
messages to perform another lookahead properly.
canProcess
in interface AbstractMessage
istream
- Input stream with incoming messagejava.lang.NullPointerException
- Parameter was null
public boolean read(java.io.InputStream istream) throws java.io.IOException
read
in interface AbstractMessage
istream
- Input stream with incoming messagejava.io.IOException
- An I/O error occurredjava.lang.NullPointerException
- Parameter was null
public boolean read(byte[] data) throws java.io.IOException
data
- Binary message datajava.io.IOException
- An I/O error occurredjava.lang.NullPointerException
- Parameter was null
public boolean write(java.io.OutputStream ostream, java.lang.String encoding) throws java.io.IOException
write
in interface AbstractMessage
ostream
- Output stream for outgoing messageencoding
- Encoding for stream, may be null
java.io.IOException
- An I/O error occurredjava.lang.NullPointerException
- Parameter was null
public boolean write(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
write
in interface AbstractMessage
request
- Servlet request with incoming messageresponse
- Servlet response for outgoing messagejava.io.IOException
- An I/O error occurredjava.lang.NullPointerException
- Parameter was null
public boolean isArmed()
isArmed
in interface AbstractMessage
public boolean isValid()
isValid
in interface AbstractMessage
public java.net.URL getDTD()
public org.jdom.Attribute getAttribute(java.lang.String expression)
expression
- XPath expressionnull
elsepublic java.lang.String getAttributeValue(java.lang.String expression)
expression
- XPath expressionnull
elsepublic org.jdom.Element getElement(java.lang.String expression)
expression
- XPath expressionnull
elsepublic java.lang.String getElementValue(java.lang.String expression)
expression
- XPath expressionnull
elsepublic java.util.List getElements(java.lang.String expression)
expression
- XPath expressionnull
elsepublic int getIntFunctionResult(java.lang.String expression)
expression
- XPath expressionnull
elsepublic void printDocument(java.lang.String encoding)
System.out
.
If executed by the Tomcat web container the output normally goes into the log file.
encoding
- Like "ISO-8859-1"public java.lang.String getContents(java.lang.String encoding)
encoding
- Like "ISO-8859-1"null
in error casepublic void setFormat(org.jdom.output.Format format)
Format.getPrettyFormat()
.
format
- Supported format (required)java.lang.NullPointerException
- If parameter is null
public org.jdom.Document getDocument()
null
public void setEncoding(java.lang.String encoding)
encoding
- The encoding (optional)public java.lang.String getEncoding()
null
Copyright © 2005-2013 Leisenfels UG (haftungsbeschränkt). All rights reserved.