JXTA

net.jxta.impl.content.srdisocket
Class ContentRequest

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

public class ContentRequest
extends Object

Implements a Content Request Message according to the schema:

 <xs:element name="ContentRequest" type="ContentRequestType"/>

 <xs:complexType name="ContentRequestType">
   <xs:sequence>
     <xs:element name="ContentID" type="xs:string"
       minOccurs="1" maxOccurs="1" />
   </xs:sequence>
 </xs:complexType>
 


Constructor Summary
ContentRequest()
          Default constructor.
ContentRequest(Element root)
          Build request object from existing XML document.
 
Method Summary
 ContentID getContentID()
          Returns Content ID of this request.
 Document getDocument(MimeMediaType asMimeType)
          Read in an XML document.
protected  boolean handleElement(Element raw)
          Process an individual element from the document during parse.
protected  void initialize(Element root)
          Intialize a Content Request from a portion of a structured document.
static ContentRequest readFromStream(InputStream in)
          Utility method to read a document transmitted with the corresponding writeToStream method.
 void setContentID(ContentID id)
          Sets the Content ID of this request.
 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

ContentRequest

public ContentRequest()
Default constructor.


ContentRequest

public ContentRequest(Element root)
Build request 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 Request 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 id)
Sets the Content ID of this request.


getContentID

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


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 ContentRequest 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