org.w3c.mwi.mobileok.basic
Interface RetrievalElement

All Known Implementing Classes:
FailedRetrievalElement, FragmentRetrievalElement, HttpRetrievalElement

public interface RetrievalElement

Interface that represents a client/server exchange when a Web resource is being retrieved.

Depending on the scheme of the URI of the Web resource being retrieved, classes that implement the interface may provide much more details on the exchange, and in particular details on the request that was sent and/or on the headers of the response that was received.

Version:
$Revision: 1.1 $
Author:
Francois Daoust

Method Summary
 java.lang.String getContentType()
          Returns the content-type of the retrieved resource.
 java.lang.String getContentTypeEncoding()
          Extracts the encoding defined along with the content-type of the resource (e.g.
 byte[] getRawBody()
          Returns the body of the retrieved resource as binary data.
 int getRawBodySize()
          Returns the size of the retrieved resource.
 java.net.URI getUri()
          Returns the absolute URI of the retrieved resource.
 org.w3c.dom.Node toMokiNode(org.w3c.dom.Document document, org.w3c.dom.Node parent, ResourceContext context)
          Serializes the retrieval element to its moki representation as a DOM node.
 

Method Detail

getRawBody

byte[] getRawBody()
Returns the body of the retrieved resource as binary data.

Returns:
the body of the retrieved resource as binary data. Returns null when the resource was too large, or when a network error occurred.

getRawBodySize

int getRawBodySize()
Returns the size of the retrieved resource.

The size is computed even when the response was too large.

Returns:
the size of the retrieved resource.

getUri

java.net.URI getUri()
Returns the absolute URI of the retrieved resource.

Returns:
the absolute URI of the response.

getContentType

java.lang.String getContentType()
Returns the content-type of the retrieved resource.

The Content-Type may either be explicitly defined, e.g. in a Content-Type HTTP header, or guessed from whatever means. The Content-Type will be used to select the most appropriate parser for the resource.

Returns:
the MIME media type of the resource.

getContentTypeEncoding

java.lang.String getContentTypeEncoding()
Extracts the encoding defined along with the content-type of the resource (e.g. within the Content-Type HTTP header received in the HTTP Response)

Returns:
the encoding defined in the Content-Type header, null if not found.

toMokiNode

org.w3c.dom.Node toMokiNode(org.w3c.dom.Document document,
                            org.w3c.dom.Node parent,
                            ResourceContext context)
Serializes the retrieval element to its moki representation as a DOM node.

Note that in an ideal world, there should be no need to pass the context that gave birth to the creation of the retrieval element as an argument, but HTTP error codes defined in mobileOK depend on the context, so it seems easier to issue the appropriate error code in the serialization rather than having to compute it afterwards depending on the location of the error code in the moki representation.

Parameters:
document - DOM document the created node should belong to
parent - DOM node to which the representation should be appended.
context - context under which the retrieval element was created. The context is needed to return the appropriate error messages when the resource could not be retrieved.
Returns:
the moki representation of the element as a DOM node.