org.apache.webdav.lib.methods

Class XMLResponseMethodBase

Known Direct 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
abstract 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 DocumentBuilder
builder
Document builder.
protected String
decodeResponseHrefs
protected 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 Summary

XMLResponseMethodBase()
Method constructor.
XMLResponseMethodBase(String uri)
Method constructor.

Method Summary

protected static Property
convertElementToProperty(XMLResponseMethodBase.Response response, Element element)
This method creates a property implementation from an element.
protected 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.
Document
getResponseDocument()
Response document getter.
protected Hashtable
getResponseHashtable()
protected Vector
getResponseURLs()
Enumeration
getResponses()
Return an enumeration containing the responses.
void
parseResponse(InputStream input, HttpState state, HttpConnection conn)
Parse response.
protected void
parseXMLResponse(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.
void
setDecodeResponseHrefs(String encoding)
Sets whether the href in responses are decoded, as early as possible.
protected void
setDocument(Document doc)
protected void
setResponseHashtable(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

getRequestContentLength, isRequestContentAlreadySet, readContinueCode, recycle, setRequestBody, setRequestBody, setRequestBody, setRequestBody, setRequestBody, writeRequestBody

Field Details

builder

protected DocumentBuilder builder
Document builder.

decodeResponseHrefs

protected String decodeResponseHrefs

responseURLs

protected 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 Details

XMLResponseMethodBase

public XMLResponseMethodBase()
Method constructor.

XMLResponseMethodBase

public XMLResponseMethodBase(String uri)
Method constructor.
Parameters:
uri - the URI to request

Method Details

convertElementToProperty

protected static Property convertElementToProperty(XMLResponseMethodBase.Response response,
                                                   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.

generateRequestBody

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

The default behavior simply returns an empty body.


getDebug

public int getDebug()
Debug property getter.

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 interface HttpRequestBodyMethodBase
Returns:
0, indicating that the request has no body.

getResponseDocument

public Document getResponseDocument()
Response document getter.
Returns:
Document response document

getResponseHashtable

protected Hashtable getResponseHashtable()

getResponseURLs

protected Vector getResponseURLs()

getResponses

public Enumeration getResponses()
Return an enumeration containing the responses.
Returns:
An enumeration containing objects implementing the ResponseEntity interface

parseResponse

public void parseResponse(InputStream input,
                          HttpState state,
                          HttpConnection conn)
            throws IOException,
                   HttpException
Parse response.
Parameters:
input - Input stream

parseXMLResponse

protected void parseXMLResponse(InputStream input)
            throws IOException,
                   HttpException

readResponseBody

protected void readResponseBody(HttpState state,
                                HttpConnection conn)
            throws IOException,
                   HttpException

recycle

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

setDebug

public void setDebug(int debug)
Debug property setter.
Parameters:

setDecodeResponseHrefs

public void setDecodeResponseHrefs(String encoding)
Sets whether the href in responses are decoded, as early as possible. The href data in responses is often url-encoded, but not alwyas in a comparable way. Set this to a non-null value to decode the hrefs as early as possible.
Parameters:
encoding - The encoding used in while decoding (UTF-8 is recommended)

setDocument

protected void setDocument(Document doc)

setResponseHashtable

protected void setResponseHashtable(Hashtable h)

writeRequestBody

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

This implementation writes any computed body and returns true.

Overrides:
writeRequestBody in interface HttpRequestBodyMethodBase
Parameters:
state - the client state
conn - the connection to write to
Returns:
true