JXTA

net.jxta.impl.content.srdisocket
Class ContentResponse

java.lang.Object
  extended by net.jxta.impl.content.srdisocket.ContentResponse

public class ContentResponse
extends Object

Implements a Content Response Message according to the schema:

 <xs:element name="ContentResponse" type="ContentResponseType"/>

 <xs:complexType name="ContentResponseType">
   <xs:sequence>
     <xs:element name="ContentID" type="xs:string"
       minOccurs="1" maxoccurs="1" />
     <xs:element name="Success" type="xs:boolean"
       minOccurs="1" maxoccurs="1" />
   </xs:sequence>
 </xs:complexType>
 


Constructor Summary
ContentResponse()
          Default constructor.
ContentResponse(ContentRequest req)
          Builds response object, initializing values from data found in request.
ContentResponse(Element root)
          Build response object from existing XML document.
 
Method Summary
 ContentID getContentID()
          Returns Content ID of this response.
 Document getDocument(MimeMediaType asMimeType)
          Read in an XML document.
 boolean getSuccess()
          Returns response status.
protected  boolean handleElement(Element raw)
          Process an individual element from the document during parse.
protected  void initialize(Element root)
          Intialize a Content Response from a portion of a structured document.
static ContentResponse readFromStream(InputStream in)
          Utility method to read a document transmitted with the corresponding writeToStream method.
 void setContentID(ContentID contentID)
          Sets the Content ID of this response.
 void setSuccess(boolean wasSuccessful)
          Sets the response status.
 void writeToStream(OutputStream out)
          Utility method to write the document to a stream with a document byte length prefixed to the data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentResponse

public ContentResponse()
Default constructor.


ContentResponse

public ContentResponse(ContentRequest req)
Builds response object, initializing values from data found in request.


ContentResponse

public ContentResponse(Element root)
Build response object from existing XML document.

Method Detail

handleElement

protected boolean handleElement(Element raw)
Process an individual element from the document during parse. Normally, implementations will allow the base advertisments a chance to handle the element before attempting ot handle the element themselves. ie.


  protected boolean handleElement(Element elem) {

      if (super.handleElement()) {
           // it's been handled.
           return true;
           }

      ... handle elements here ...

      // we don't know how to handle the element
      return false;
      }
  

Parameters:
raw - the element to be processed.
Returns:
true if the element was recognized, otherwise false.

initialize

protected void initialize(Element root)
Intialize a Content Response from a portion of a structured document.

Parameters:
root - document to intialize from

getDocument

public Document getDocument(MimeMediaType asMimeType)
Read in an XML document.


setContentID

public void setContentID(ContentID contentID)
Sets the Content ID of this response.


getContentID

public ContentID getContentID()
Returns Content ID of this response.


setSuccess

public void setSuccess(boolean wasSuccessful)
Sets the response status.


getSuccess

public boolean getSuccess()
Returns response status.


writeToStream

public void writeToStream(OutputStream out)
                   throws IOException
Utility method to write the document to a stream with a document byte length prefixed to the data.

Parameters:
out - stream to write document to
Throws:
IOException

readFromStream

public static ContentResponse readFromStream(InputStream in)
                                      throws IOException
Utility method to read a document transmitted with the corresponding writeToStream method.

Parameters:
in - stream to read document from
Returns:
response object
Throws:
IOException

JXSE