org.eclipse.webdav.internal.kernel
Class Response

java.lang.Object
  extended by org.eclipse.webdav.internal.kernel.Message
      extended by org.eclipse.webdav.internal.kernel.Response
All Implemented Interfaces:
IResponse

public class Response
extends Message
implements IResponse

The Response class subclasses Message to add a status field.


Field Summary
protected  Status status
           
 
Fields inherited from class org.eclipse.webdav.internal.kernel.Message
body, context
 
Fields inherited from interface org.eclipse.webdav.IResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_CROSS_SERVER_BINDING_FORBIDDEN, SC_FAILED_DEPENDENCY, SC_FORBIDDEN, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INSUFFICIENT_SPACE_ON_RESOURCE, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_LOCKED, SC_LOOP_DETECTED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTI_STATUS, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROCESSING, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_TIMEOUT, SC_REQUEST_TOO_LONG, SC_REQUEST_URI_TOO_LONG, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_UNAUTHORIZED, SC_UNPROCESSABLE_ENTITY, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
 
Constructor Summary
Response(Status status, IContext context, Document body)
           
Response(Status status, IContext context, InputStream body)
           
 
Method Summary
 void close()
          Closes this response.
 Document getDocumentBody()
          Gets the contents of the response body as a DOM Document.
 InputStream getInputStream()
          Returns an open input stream for reading the the body of this response.
 int getStatusCode()
          Return the status code for this response.
 String getStatusMessage()
          Return the status message for this response.
 boolean hasDocumentBody()
          Returns whether this response has an XML element as a body; this is the element that would be read if readDocumentBody() was called.
 String toString()
           
 
Methods inherited from class org.eclipse.webdav.internal.kernel.Message
getBody, getContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.webdav.IResponse
getContext
 

Field Detail

status

protected Status status
Constructor Detail

Response

public Response(Status status,
                IContext context,
                InputStream body)

Response

public Response(Status status,
                IContext context,
                Document body)
Method Detail

close

public void close()
           throws IOException
Description copied from interface: IResponse
Closes this response. Any unread bytes that make up the body of this response are discarded; any underlying OS resources associated with this response are freed.

This method should be invoked on every response returned from the server without exception.

Specified by:
close in interface IResponse
Throws:
IOException - if there was a problem closing this response

getDocumentBody

public Document getDocumentBody()
                         throws IOException
Description copied from interface: IResponse
Gets the contents of the response body as a DOM Document.

This response MUST have an XML body (i.e., hasDocumentBody() must return true).

Once the body has been read as an InputStream it cannot be subsequently read as a Document (the bytes have been consumed).

If a problem occurs parsing the document body an IOException is thrown.

Specified by:
getDocumentBody in interface IResponse
Returns:
DOM document obtained from the XML body.
Throws:
IOException - if there was a problem receiving the response or interpreting it as XML.

getInputStream

public InputStream getInputStream()
Description copied from interface: IResponse
Returns an open input stream for reading the the body of this response.

This response must not have an XML body (i.e., hasElementBody() must return false ).

The client may close the stream early, however, the resulting stream will be closed if necessary when the client closes this response.

Specified by:
getInputStream in interface IResponse
Returns:
the bytes of the response as an InputStream.

getStatusCode

public int getStatusCode()
Return the status code for this response.

Implements the corresponding API in the interface Response.

Specified by:
getStatusCode in interface IResponse
Returns:
the status code
See Also:
getStatusCode()

getStatusMessage

public String getStatusMessage()
Return the status message for this response.

Implements the corresponding API in the interface Response.

Specified by:
getStatusMessage in interface IResponse
Returns:
the status message
See Also:
getStatusMessage()

hasDocumentBody

public boolean hasDocumentBody()
Description copied from interface: IResponse
Returns whether this response has an XML element as a body; this is the element that would be read if readDocumentBody() was called.

This method can be called numerous times, and can be called after the body has been read either as an InputStream or a Document -- all with no bad effect.

Specified by:
hasDocumentBody in interface IResponse
Returns:
true if this message has a document body and false otherwise.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.