org.apache.webdav.lib.methods
Class XMLResponseMethodBase

java.lang.Object
  extended byorg.apache.commons.httpclient.HttpMethodBase
      extended byorg.apache.webdav.lib.methods.HttpRequestBodyMethodBase
          extended byorg.apache.webdav.lib.methods.XMLResponseMethodBase
All Implemented Interfaces:
HttpMethod
Direct Known Subclasses:
AclMethod, AclReportMethod, BindMethod, CheckinMethod, CheckoutMethod, CopyMethod, DeleteMethod, LabelMethod, LockMethod, MkWorkspaceMethod, MoveMethod, OptionsMethod, PollMethod, PropFindMethod, PropPatchMethod, RebindMethod, ReportMethod, SearchMethod, SubscribeMethod, UnbindMethod, UncheckoutMethod, UnlockMethod, UnsubscribeMethod, UpdateMethod, VersionControlMethod

public abstract class XMLResponseMethodBase
extends HttpRequestBodyMethodBase

Utility class for XML response parsing.


Nested Class Summary
(package private)  class XMLResponseMethodBase.OptionsResponse
           
 class XMLResponseMethodBase.Response
          An abstract class that models a DAV:response.
(package private)  class XMLResponseMethodBase.ResponseWithinMultistatus
          A class that models the DAV:response element within a multistatus.
(package private)  class XMLResponseMethodBase.SingleResponse
           
 
Field Summary
protected  javax.xml.parsers.DocumentBuilder builder
          Document builder.
protected  java.util.Vector responseURLs
          Vector of response nodes, to keep track of insertion order FIXME: the above Hashtable and this Vector should be ported to plain Collections
 
Fields inherited from class org.apache.commons.httpclient.HttpMethodBase
USER_AGENT
 
Constructor Summary
XMLResponseMethodBase()
          Method constructor.
XMLResponseMethodBase(java.lang.String uri)
          Method constructor.
 
Method Summary
protected static Property convertElementToProperty(XMLResponseMethodBase.Response response, org.w3c.dom.Element element)
          This method creates a property implementation from an element.
protected  java.lang.String generateRequestBody()
          DAV requests that contain a body must override this function to generate that body.
 int getDebug()
          Debug property getter.
protected  int getRequestContentLength()
          Return the length (in bytes) of my request body, suitable for use in a Content-Length header.
 org.w3c.dom.Document getResponseDocument()
          Response document getter.
protected  java.util.Hashtable getResponseHashtable()
           
 java.util.Enumeration getResponses()
          Return an enumeration containing the responses.
protected  java.util.Vector getResponseURLs()
           
 void parseResponse(java.io.InputStream input, HttpState state, HttpConnection conn)
          Parse response.
protected  void parseXMLResponse(java.io.InputStream input)
           
protected  void readResponseBody(HttpState state, HttpConnection conn)
           
 void recycle()
          Reset the State of the class to its initial state, so that it can be used again.
 void setDebug(int debug)
          Debug property setter.
protected  void setDocument(org.w3c.dom.Document doc)
           
protected  void setResponseHashtable(java.util.Hashtable h)
           
protected  boolean writeRequestBody(HttpState state, HttpConnection conn)
          Write the request body to the given HttpConnection.
 
Methods inherited from class org.apache.webdav.lib.methods.HttpRequestBodyMethodBase
isRequestContentAlreadySet, readContinueCode, setRequestBody, setRequestBody, setRequestBody, setRequestBody, setRequestBody
 
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
addAuthorizationRequestHeader, addContentLengthRequestHeader, addCookieRequestHeader, addHostRequestHeader, addProxyAuthorizationRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, fakeResponse, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getFollowRedirects, getHostConfiguration, getMethodRetryHandler, getName, getPath, getProxyAuthenticationRealm, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isConnectionCloseForced, isHttp11, isStrictMode, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, shouldCloseConnection, validate, writeRequest, writeRequestHeaders, writeRequestLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

builder

protected javax.xml.parsers.DocumentBuilder builder
Document builder.


responseURLs

protected java.util.Vector responseURLs
Vector of response nodes, to keep track of insertion order FIXME: the above Hashtable and this Vector should be ported to plain Collections

Constructor Detail

XMLResponseMethodBase

public XMLResponseMethodBase()
Method constructor.


XMLResponseMethodBase

public XMLResponseMethodBase(java.lang.String uri)
Method constructor.

Parameters:
uri - the URI to request
Method Detail

getResponseDocument

public org.w3c.dom.Document getResponseDocument()
Response document getter.

Returns:
Document response document

getResponses

public java.util.Enumeration getResponses()
Return an enumeration containing the responses.

Returns:
An enumeration containing objects implementing the ResponseEntity interface

setDebug

public void setDebug(int debug)
Debug property setter.


getDebug

public int getDebug()
Debug property getter.


recycle

public void recycle()
Reset the State of the class to its initial state, so that it can be used again.

Specified by:
recycle in interface HttpMethod
Overrides:
recycle in class HttpRequestBodyMethodBase

readResponseBody

protected void readResponseBody(HttpState state,
                                HttpConnection conn)
                         throws java.io.IOException,
                                HttpException
Throws:
java.io.IOException
HttpException

getRequestContentLength

protected int getRequestContentLength()
Return the length (in bytes) of my request body, suitable for use in a Content-Length header.

Return -1 when the content-length is unknown.

This implementation returns 0, indicating that the request has no body.

Overrides:
getRequestContentLength in class HttpRequestBodyMethodBase
Returns:
0, indicating that the request has no body.

generateRequestBody

protected java.lang.String generateRequestBody()
DAV requests that contain a body must override this function to generate that body.

The default behavior simply returns an empty body.


writeRequestBody

protected boolean writeRequestBody(HttpState state,
                                   HttpConnection conn)
                            throws java.io.IOException,
                                   HttpException
Write the request body to the given HttpConnection.

This implementation writes any computed body and returns true.

Overrides:
writeRequestBody in class HttpRequestBodyMethodBase
Parameters:
state - the client state
conn - the connection to write to
Returns:
true
Throws:
java.io.IOException - when i/o errors occur reading the response
HttpException - when a protocol error occurs or state is invalid

parseResponse

public void parseResponse(java.io.InputStream input,
                          HttpState state,
                          HttpConnection conn)
                   throws java.io.IOException,
                          HttpException
Parse response.

Parameters:
input - Input stream
Throws:
java.io.IOException
HttpException

parseXMLResponse

protected void parseXMLResponse(java.io.InputStream input)
                         throws java.io.IOException,
                                HttpException
Throws:
java.io.IOException
HttpException

getResponseHashtable

protected java.util.Hashtable getResponseHashtable()

getResponseURLs

protected java.util.Vector getResponseURLs()

convertElementToProperty

protected static Property convertElementToProperty(XMLResponseMethodBase.Response response,
                                                   org.w3c.dom.Element element)
This method creates a property implementation from an element. It treats known properties (i.e., the DAV properties) specially. These properties are instantiated as an implementation from the org.apache.webdav.lib.properties package.


setDocument

protected void setDocument(org.w3c.dom.Document doc)

setResponseHashtable

protected void setResponseHashtable(java.util.Hashtable h)