org.eclipse.webdav.dom
Class ResponseBody

java.lang.Object
  extended by org.eclipse.webdav.dom.ElementEditor
      extended by org.eclipse.webdav.dom.ResponseBody

public class ResponseBody
extends ElementEditor

An element editor for the WebDAV response element. See RFC2518 section 12.9.1 for the element's definition.

Note: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

See Also:
MultiStatus, PropStat

Field Summary
protected static String[] childNames
          An ordered collection of the element names of the responsebody element's children.
static String[] fgNamesPropStat
          An ordered collection of the element names of the responsebody element's children in the "propstat" form.
static String[] fgNamesStatus
          An ordered collection of the element names of the responsebody element's children in the "status" form.
 
Fields inherited from class org.eclipse.webdav.dom.ElementEditor
DAV_NS, root, XML_NS_NAME, XML_NS_PREFIX, XML_PREFIX
 
Constructor Summary
ResponseBody(Element root)
          Creates a new editor on the given WebDAV response element.
 
Method Summary
 PropStat accumulatePropStat(Element element, String status, String responseDescription)
          Gets this response's first propstat with the given status and adds a clone of the given element as a property of its prop.
 PropStat accumulatePropStat(QualifiedName propertyName, String status, String responseDescription)
          Gets this response's first propstat with the given status and adds an element created from the given property name as a property of the propstat's prop.
 void addHref(String href)
          Adds the given href to this response.
 PropStat addPropStat()
          Creates and adds a propstat element on this response and returns an editor on it.
 void changePropStatStatus(String oldStatus, String newStatus, String responseDescription)
          Changes all of this response's propstats with the given old status to have the given new status.
static ResponseBody create(Document document)
          Creates a new WebDAV response element and sets it as the root of the given document.
 String getHref()
          Returns this response's first href.
 Enumeration getHrefs()
          Returns an Enumeration of this response's hrefs (not including the first href).
 Enumeration getPropStats()
          Returns an Enumeration of this response's Propstats.
 String getResponseDescription()
          Returns this response's response description, or null if it has none.
 String getStatus()
          Returns this response's status.
 int getStatusCode()
          Returns this response's status code.
 boolean isPropStat()
          Returns true if this response is in "propstat" form and false if it is in "status" form.
 boolean isStatus()
          Returns true if this response is in "status" form and false if it is in "propstat" form.
 void setHref(String href)
          Sets this response's first href to the given href.
 void setResponseDescription(Element value)
          Sets this response's response description to the given value.
 void setResponseDescription(String value)
          Sets this response's response description to the given value.
 void setStatus(String status)
          Sets the status on this response to the given status.
 
Methods inherited from class org.eclipse.webdav.dom.ElementEditor
addChild, addChild, addChild, appendChild, appendChild, cloneNode, create, declareNS, decodeHref, encodeHref, ensure, ensure, ensureDAVElement, ensureDAVElement, ensureNotNull, ensureNull, ensureText, extractElement, extractNode, getChild, getChildElement, getChildText, getDAVChild, getElement, getFirstChild, getFirstChild, getFirstText, getLastChild, getNamespaces, getNamespaces, getNextSibling, getNextSibling, getNextSibling, getNSLocalName, getNSLocalName, getNSName, getNSPrefix, getNSPrefix, getQualifiedName, getSibling, getText, getTwin, hasChild, insertBefore, insertBefore, isDAVElement, isDAVElement, isElement, isText, makeNSStandalone, reduceNS, reduceNS, resolve, setChild, setChild, setChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

childNames

protected static final String[] childNames
An ordered collection of the element names of the responsebody element's children.


fgNamesStatus

public static String[] fgNamesStatus
An ordered collection of the element names of the responsebody element's children in the "status" form.


fgNamesPropStat

public static String[] fgNamesPropStat
An ordered collection of the element names of the responsebody element's children in the "propstat" form.

Constructor Detail

ResponseBody

public ResponseBody(Element root)
             throws MalformedElementException
Creates a new editor on the given WebDAV response element. The element is assumed to be well formed.

Parameters:
root - a response element
Throws:
MalformedElementException - if there is reason to believe that the element is not well formed
Method Detail

accumulatePropStat

public PropStat accumulatePropStat(QualifiedName propertyName,
                                   String status,
                                   String responseDescription)
Gets this response's first propstat with the given status and adds an element created from the given property name as a property of the propstat's prop. If such a propstat does not exists, it is created. The propstat's response description is set to the given response description, or removed if the response description is null. Returns the propstat. The property name must not be null and its qualifier and local part must not be null and must not be the empty string. The status must not be null. This response must not already be in the "status" form.

Parameters:
propertyName - the name of the property to create and add
status - the status of the propstat to add the property element to
responseDescription - the new response description of the propstat, or null to remove the old one
Returns:
a propstat with the specified property element, status, and response description

accumulatePropStat

public PropStat accumulatePropStat(Element element,
                                   String status,
                                   String responseDescription)
                            throws MalformedElementException
Gets this response's first propstat with the given status and adds a clone of the given element as a property of its prop. If such a propstat does not exists, it is created. The propstat's response description is set to the given response description, or removed if the response description is null. Returns the propstat. The element and status must not be null. This response must not already be in the "status" form.

Parameters:
element - the property element being added
status - the status of the propstat to add the property element to
responseDescription - the new response description of the propstat, or null to remove the old one
Returns:
a propstat with the given property element, status, and response description
Throws:
MalformedElementException - if there is reason to believe that the given element is not well formed

addHref

public void addHref(String href)
Adds the given href to this response. If setHref(String) hasn't been called and no hrefs have been added, this method sets the first href and is thus equivalent to setHref(String). The href must not be null. This response must not already be in "propstat" form.

Parameters:
href - the href to add

addPropStat

public PropStat addPropStat()
Creates and adds a propstat element on this response and returns an editor on it.

Returns:
an editor on a propstat element

changePropStatStatus

public void changePropStatStatus(String oldStatus,
                                 String newStatus,
                                 String responseDescription)
Changes all of this response's propstats with the given old status to have the given new status. In addition, their response descriptions are changed to be the given response description or removed if the given response description is null. The old status and new status must not be null. This response must not be in the "status" form.

Parameters:
oldStatus - the old status of the propstat's that are changed
newStatus - the new status of the propstat's that are changed
responseDescription - the new response description of the propstat's that are changed, or null

create

public static ResponseBody create(Document document)
Creates a new WebDAV response element and sets it as the root of the given document. Returns an editor on the new response element. The document must not be null, and must not already have a root element.

Parameters:
document - the document that will become the root of a new response element
Returns:
an element editor on a response element

getHref

public String getHref()
               throws MalformedElementException
Returns this response's first href.

Returns:
this response's first href.
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed

getHrefs

public Enumeration getHrefs()
                     throws MalformedElementException
Returns an Enumeration of this response's hrefs (not including the first href).

Returns:
an Enumeration of this response's href Strings
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed, or if this response is not in "status" form

getPropStats

public Enumeration getPropStats()
                         throws MalformedElementException
Returns an Enumeration of this response's Propstats.

Returns:
an Enumeration of this response's PropStats
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed, or if this response is not in "propstat" form

getResponseDescription

public String getResponseDescription()
                              throws MalformedElementException
Returns this response's response description, or null if it has none.

Returns:
this response's response description, or null
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed

getStatus

public String getStatus()
                 throws MalformedElementException
Returns this response's status.

Returns:
this response's status
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed, or if this response is not in "status" form

getStatusCode

public int getStatusCode()
                  throws MalformedElementException
Returns this response's status code.

Returns:
this response's status code
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed, or if this response is not in "status" form

isPropStat

public boolean isPropStat()
                   throws MalformedElementException
Returns true if this response is in "propstat" form and false if it is in "status" form.

Returns:
a boolean indicating whether this response is in "propstat" or "status" form
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed

isStatus

public boolean isStatus()
                 throws MalformedElementException
Returns true if this response is in "status" form and false if it is in "propstat" form.

Returns:
a boolean indicating whether this response is in "status" or "propstat" form
Throws:
MalformedElementException - if there is reason to believe that this editor's underlying element is not well formed

setHref

public void setHref(String href)
Sets this response's first href to the given href. The href must not be null.

Parameters:
href - the href to set this response's first href to

setResponseDescription

public void setResponseDescription(String value)
Sets this response's response description to the given value. If the value is null and a response description has already been set, it is removed.

Parameters:
value - a response description, or null

setResponseDescription

public void setResponseDescription(Element value)
Sets this response's response description to the given value. If the value is null and a response description has already been set, it is removed.

Parameters:
value - a response description, or null

setStatus

public void setStatus(String status)
Sets the status on this response to the given status. The status must not be null. This response must not already be in the "propstat" form.

Parameters:
status - the status for this response


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