org.w3c.mwi.mobileok.basic
Class FragmentRetrievalElement

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

public class FragmentRetrievalElement
extends java.lang.Object
implements RetrievalElement

An instance of the class represents a textual fragment of a retrieved resource.

The goal of the class is to define specific resources that are contained within another resource. As a typical example, this class is used to represent embedded and inline CSS styles within an XHTML page.

Version:
$Revision: 1.1 $
Author:
Francois Daoust

Field Summary
private  FragmentBoxType boxType
          Box type of the fragment (block or inline).
private  java.lang.String contentType
          Fragment Content-Type
private  int line
          Starting line number of the fragment within the original resource.
private  byte[] rawBody
          Fragment, encoded as UTF-8.
private  int rawBodySize
          Fragment size.
private  java.net.URI uri
          URI of the retrieved resource.
 
Constructor Summary
FragmentRetrievalElement(java.net.URI uri, java.lang.String fragment, java.lang.String contentType, FragmentBoxType boxType, int line)
          Creates a class instance from the given textual section.
 
Method Summary
 FragmentBoxType getBoxType()
          Returns the box type of the fragment (block or inline).
 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.
 int getLine()
          Returns the starting line of the fragment within its containing resource.
 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, and in practice returns null because fragment content is by definition embedded in some other resource, and thus was not retrieved per se.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uri

private final java.net.URI uri
URI of the retrieved resource.


rawBody

private byte[] rawBody
Fragment, encoded as UTF-8.


rawBodySize

private final int rawBodySize
Fragment size.


contentType

private final java.lang.String contentType
Fragment Content-Type


boxType

private final FragmentBoxType boxType
Box type of the fragment (block or inline).


line

private final int line
Starting line number of the fragment within the original resource.

Constructor Detail

FragmentRetrievalElement

public FragmentRetrievalElement(java.net.URI uri,
                                java.lang.String fragment,
                                java.lang.String contentType,
                                FragmentBoxType boxType,
                                int line)
Creates a class instance from the given textual section.

Parameters:
uri - Absolute URI of the underlying resource.
fragment - Textual fragment to represent
contentType - Content-Type of the fragment
boxType - Box type of the fragment
line - Line where the section starts, -1 means not set.
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.

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.

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.

getLine

public int getLine()
Returns the starting line of the fragment within its containing resource.

Returns:
the starting line of the fragment. -1 means not set.

getBoxType

public FragmentBoxType getBoxType()
Returns the box type of the fragment (block or inline).

Returns:
the box type of the fragment.

toMokiNode

public 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, and in practice returns null because fragment content is by definition embedded in some other resource, and thus was not retrieved per se.

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.