Package com.iizix.ws.engine.xml
Class XMLReply
- java.lang.Object
- com.iizix.ws.engine.xml.XMLReply
- All Implemented Interfaces:
IReplyContent
public class XMLReply extends java.lang.Object implements IReplyContent
Class for a JSON reply.- Author:
- Christopher Mindus
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanFormat()Checks if formatting the output is supported.java.lang.StringformatHTTPReply()Formats the URLConnection HTTP headers reply into a String.java.lang.StringgetAcceptedContent()Gets the accepted contents.java.lang.StringgetDescription()Gets the format description.org.w3c.dom.DocumentgetDocumentReply()Gets the reply document.org.w3c.dom.ElementgetElementFromPath(java.lang.String path)Gets an Element with specified path.java.lang.StringgetRawOutput(boolean doFormat)Gets the raw text data from the reply.java.lang.StringgetStringFromPath(java.lang.String path)Gets the String reply data with specified path.booleanisHandled(java.lang.String type)Checks if a content type is handled by this reply.voidreadReply(RESTfulReply reply, java.lang.String data)Called to format the request for this reply content, i.e.
Method Detail
getAcceptedContent
public java.lang.String getAcceptedContent()
Gets the accepted contents.- Specified by:
getAcceptedContentin interfaceIReplyContent- Returns:
- A String such as "text/html" or "text/plain, text/html".
isHandled
public boolean isHandled(java.lang.String type)
Checks if a content type is handled by this reply.- Specified by:
isHandledin interfaceIReplyContent- Parameters:
type- The content type from the HTTP header "Content-Type", without "charset". The type is in lower case.- Returns:
- true if handled, false otherwise.
readReply
public void readReply(RESTfulReply reply, java.lang.String data) throws java.io.IOException
Called to format the request for this reply content, i.e. the accepted content.- Specified by:
readReplyin interfaceIReplyContent- Parameters:
reply- The reply instance.data- The String data from the reply.- Throws:
java.io.IOException- For I/O errors.
getDocumentReply
public org.w3c.dom.Document getDocumentReply()
Gets the reply document.- Returns:
- The document.
canFormat
public boolean canFormat()
Checks if formatting the output is supported.- Specified by:
canFormatin interfaceIReplyContent- Returns:
- true If formatting is supported.
getDescription
public java.lang.String getDescription()
Gets the format description.- Specified by:
getDescriptionin interfaceIReplyContent- Returns:
- The description string.
formatHTTPReply
public java.lang.String formatHTTPReply()
Formats the URLConnection HTTP headers reply into a String.- Specified by:
formatHTTPReplyin interfaceIReplyContent- Returns:
- The formatted HTML reply string.
getRawOutput
public java.lang.String getRawOutput(boolean doFormat)
Gets the raw text data from the reply.- Specified by:
getRawOutputin interfaceIReplyContent- Parameters:
doFormat- Flag to format the output (used for JSON and XML).- Returns:
- The String of the reply, or null if an exception occurred.
getElementFromPath
public org.w3c.dom.Element getElementFromPath(java.lang.String path)
Gets an Element with specified path.- Parameters:
path- The path to look-up.- Returns:
- The element found.
getStringFromPath
public java.lang.String getStringFromPath(java.lang.String path)
Gets the String reply data with specified path.- Parameters:
path- The path to look-up.- Returns:
- The data, or null if not found.