org.w3c.mwi.mobileok.basic
Class FailedRetrievalElement

java.lang.Object
  extended by org.w3c.mwi.mobileok.basic.FailedRetrievalElement
All Implemented Interfaces:
RetrievalElement

public class FailedRetrievalElement
extends java.lang.Object
implements RetrievalElement

An instance of the class represents an exchange that failed during while trying to retrieve a resource

Version:
$Revision: 1.1 $
Author:
Francois Daoust

Field Summary
private  java.lang.Exception exception
          Exception that was raised when retrieval failed.
 
Constructor Summary
FailedRetrievalElement(java.lang.Exception exception)
          Creates an instance from the given exception.
 
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.
 java.lang.Exception getException()
          Returns the exception that was raised when retrieval failed.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exception

private java.lang.Exception exception
Exception that was raised when retrieval failed.

Constructor Detail

FailedRetrievalElement

public FailedRetrievalElement(java.lang.Exception exception)
Creates an instance from the given exception.

Parameters:
exception - exception that was raised when retrieval failed.
Method Detail

getContentType

public java.lang.String getContentType()
Description copied from interface: RetrievalElement
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.

Specified by:
getContentType in interface RetrievalElement
Returns:
the MIME media type of the resource.

getRawBody

public byte[] getRawBody()
Description copied from interface: RetrievalElement
Returns the body of the retrieved resource as binary data.

Specified by:
getRawBody in interface RetrievalElement
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

public int getRawBodySize()
Description copied from interface: RetrievalElement
Returns the size of the retrieved resource.

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

Specified by:
getRawBodySize in interface RetrievalElement
Returns:
the size of the retrieved resource.

getUri

public java.net.URI getUri()
Description copied from interface: RetrievalElement
Returns the absolute URI of the retrieved resource.

Specified by:
getUri in interface RetrievalElement
Returns:
the absolute URI of the response.

getException

public java.lang.Exception getException()
Returns the exception that was raised when retrieval failed.

Returns:
the exception that prevented the retrieval of the resource.

toMokiNode

public org.w3c.dom.Node toMokiNode(org.w3c.dom.Document document,
                                   org.w3c.dom.Node parent,
                                   ResourceContext context)
Description copied from interface: RetrievalElement
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.

Specified by:
toMokiNode in interface RetrievalElement
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.

getContentTypeEncoding

public java.lang.String getContentTypeEncoding()
Description copied from interface: RetrievalElement
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)

Specified by:
getContentTypeEncoding in interface RetrievalElement
Returns:
the encoding defined in the Content-Type header, null if not found.