org.wso2.carbon.registry.app
Class StringResponseContext

java.lang.Object
  extended by org.apache.abdera.protocol.util.AbstractMessage
      extended by org.apache.abdera.protocol.util.AbstractResponse
          extended by org.apache.abdera.protocol.server.context.AbstractResponseContext
              extended by org.wso2.carbon.registry.app.StringResponseContext
All Implemented Interfaces:
org.apache.abdera.protocol.Message, org.apache.abdera.protocol.Response, org.apache.abdera.protocol.server.ResponseContext, org.apache.abdera.protocol.util.ProtocolConstants

public class StringResponseContext
extends org.apache.abdera.protocol.server.context.AbstractResponseContext

Custom ResponseContext which allows us to return a simple string message inside a <result> element, with a specified response code.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.abdera.protocol.Response
org.apache.abdera.protocol.Response.ResponseType
 
Field Summary
 
Fields inherited from class org.apache.abdera.protocol.server.context.AbstractResponseContext
binary, EMPTY, headers, status, status_text, writer
 
Fields inherited from class org.apache.abdera.protocol.util.AbstractResponse
nocache_headers, private_headers, smax_age
 
Fields inherited from class org.apache.abdera.protocol.util.AbstractMessage
flags, max_age
 
Fields inherited from interface org.apache.abdera.protocol.util.ProtocolConstants
NOCACHE, NOSTORE, NOTRANSFORM, ONLYIFCACHED, PRIVATE, PROXYREVALIDATE, PUBLIC, REVALIDATE
 
Constructor Summary
StringResponseContext(Exception e, int status)
          Creates a response that can contain a message.
StringResponseContext(String message, int status)
          Creates a response that can contain a message.
 
Method Summary
 boolean hasEntity()
          Whether the response contains an entity.
 void writeTo(OutputStream outputStream)
          Method to write the message in to given output.
 void writeTo(OutputStream outputStream, org.apache.abdera.writer.Writer abderaWriter)
          Method to write the message in to given output.
 void writeTo(Writer writer)
          Method to write the message in to given output.
 void writeTo(Writer writer, org.apache.abdera.writer.Writer abderaWriter)
          Method to write the message in to given output.
 
Methods inherited from class org.apache.abdera.protocol.server.context.AbstractResponseContext
addEncodedHeader, addEncodedHeaders, addHeader, addHeaders, getCacheControl, getDateHeader, getHeader, getHeaderNames, getHeaders, getHeaders, getStatus, getStatusText, isBinary, removeHeader, setAge, setAllow, setAllow, setBinary, setContentLanguage, setContentLength, setContentLocation, setContentType, setContentType, setEncodedHeader, setEncodedHeader, setEntityTag, setEntityTag, setEscapedHeader, setExpires, setHeader, setHeader, setLastModified, setLocation, setSlug, setStatus, setStatusText, setWriter
 
Methods inherited from class org.apache.abdera.protocol.util.AbstractResponse
getAge, getAllow, getContentLength, getEntityTag, getExpires, getLastModified, getLocation, getNoCacheHeaders, getPrivateHeaders, getSMaxAge, getType, isMustRevalidate, isPrivate, isProxyRevalidate, isPublic, setMaxAge, setMustRevalidate, setNoCache, setNoCacheHeaders, setNoStore, setNoTransform, setPrivate, setPrivateHeaders, setProxyRevalidate, setPublic
 
Methods inherited from class org.apache.abdera.protocol.util.AbstractMessage
check, getContentLanguage, getContentLocation, getContentType, getDecodedHeader, getDecodedHeaders, getMaxAge, getSlug, isNoCache, isNoStore, isNoTransform, toggle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.abdera.protocol.Response
getAge, getAllow, getContentLength, getEntityTag, getExpires, getLastModified, getLocation, getNoCacheHeaders, getPrivateHeaders, getSMaxAge, getType, isMustRevalidate, isPrivate, isProxyRevalidate, isPublic
 
Methods inherited from interface org.apache.abdera.protocol.Message
getContentLanguage, getContentLocation, getContentType, getDecodedHeader, getDecodedHeaders, getMaxAge, getSlug, isNoCache, isNoStore, isNoTransform
 

Constructor Detail

StringResponseContext

public StringResponseContext(String message,
                             int status)
Creates a response that can contain a message.

Parameters:
message - the message.
status - the status

StringResponseContext

public StringResponseContext(Exception e,
                             int status)
Creates a response that can contain a message.

Parameters:
e - the exception.
status - the status
Method Detail

hasEntity

public boolean hasEntity()
Whether the response contains an entity.

Returns:
true if the response contains an entity

writeTo

public void writeTo(OutputStream outputStream)
             throws IOException
Method to write the message in to given output.

Parameters:
outputStream - the output stream of the HTTP response
Throws:
IOException - if an error occurred.

writeTo

public void writeTo(Writer writer)
             throws IOException
Method to write the message in to given output.

Parameters:
writer - the Writer connected to the HTTP response
Throws:
IOException - if an error occurred.

writeTo

public void writeTo(OutputStream outputStream,
                    org.apache.abdera.writer.Writer abderaWriter)
             throws IOException
Method to write the message in to given output.

Parameters:
abderaWriter - the abdera writer.
outputStream - the output stream of the HTTP response.
Throws:
IOException - if an error occurred.

writeTo

public void writeTo(Writer writer,
                    org.apache.abdera.writer.Writer abderaWriter)
             throws IOException
Method to write the message in to given output.

Parameters:
abderaWriter - the abdera writer.
writer - the Writer connected to the HTTP response.
Throws:
IOException - if an error occurred.


Copyright © 2011 WSO2 Inc. All Rights Reserved.