Package com.iizix.ws.engine
Class TextReply
- java.lang.Object
- com.iizix.ws.engine.TextReply
- All Implemented Interfaces:
IReplyContent
public class TextReply extends java.lang.Object implements IReplyContent
Class for a "text/*" reply used for plain or HTML text.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description TextReply(boolean isPlain)
Constructs the text reply for Plain or HTML format.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canFormat()
Checks if formatting the output is supported.java.lang.String
formatHTTPReply()
Formats the URLConnection HTTP headers reply into a String.java.lang.String
getAcceptedContent()
Gets the accepted contents.java.lang.String
getDescription()
Gets the format description.java.lang.String
getRawOutput(boolean doFormat)
Gets the raw text data from the reply.java.lang.String
getReplyData()
Gets the reply data.java.lang.String
getType()
Gets the accepted type.boolean
isHandled(java.lang.String type)
Checks if a content type is handled by this reply.void
readReply(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:
getAcceptedContent
in 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:
isHandled
in 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.
getType
public java.lang.String getType()
Gets the accepted type.- Returns:
- The type "text/...".
readReply
public void readReply(RESTfulReply reply, java.lang.String data)
Called to format the request for this reply content, i.e. the accepted content.- Specified by:
readReply
in interfaceIReplyContent
- Parameters:
reply
- The reply instance.data
- The String data from the reply.
getReplyData
public java.lang.String getReplyData()
Gets the reply data.- Returns:
- The raw reply unparsed data.
canFormat
public boolean canFormat()
Checks if formatting the output is supported.- Specified by:
canFormat
in interfaceIReplyContent
- Returns:
- true If formatting is supported.
getDescription
public java.lang.String getDescription()
Gets the format description.- Specified by:
getDescription
in interfaceIReplyContent
- Returns:
- The description string.
formatHTTPReply
public java.lang.String formatHTTPReply()
Formats the URLConnection HTTP headers reply into a String.- Specified by:
formatHTTPReply
in 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:
getRawOutput
in 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.