org.restlet.resource
Class DomRepresentation

java.lang.Object
  extended by org.restlet.resource.Variant
      extended by org.restlet.resource.Representation
          extended by org.restlet.resource.StreamRepresentation
              extended by org.restlet.resource.OutputRepresentation
                  extended by org.restlet.resource.XmlRepresentation
                      extended by org.restlet.resource.DomRepresentation
All Implemented Interfaces:
NamespaceContext

public class DomRepresentation
extends XmlRepresentation

XML representation based on a DOM document. DOM is a standard XML object model defined by the W3C.

Author:
Jerome Louvel (contact@noelios.com)

Field Summary
 
Fields inherited from class org.restlet.resource.Variant
UNKNOWN_SIZE
 
Constructor Summary
DomRepresentation(MediaType mediaType)
          Constructor for an empty document.
DomRepresentation(MediaType mediaType, Document xmlDocument)
          Constructor from an existing DOM document.
DomRepresentation(Representation xmlRepresentation)
          Constructor.
 
Method Summary
 Object evaluate(String expression, QName returnType)
          Evaluates an XPath expression and returns the result as in the given return type.
 Document getDocument()
          Returns the wrapped DOM document.
 void setDocument(Document dom)
          Sets the wrapped DOM document.
 void write(OutputStream outputStream)
          Writes the representation to a byte stream.
 
Methods inherited from class org.restlet.resource.XmlRepresentation
getBoolean, getNamespaceURI, getNode, getNodes, getNumber, getPrefix, getPrefixes, getText, isNamespaceAware, putNamespace, setNamespaceAware
 
Methods inherited from class org.restlet.resource.OutputRepresentation
getStream
 
Methods inherited from class org.restlet.resource.StreamRepresentation
getChannel, write
 
Methods inherited from class org.restlet.resource.Representation
getText, isAvailable, isTransient, setAvailable, setTransient
 
Methods inherited from class org.restlet.resource.Variant
getCharacterSet, getEncodings, getExpirationDate, getIdentifier, getLanguages, getMediaType, getModificationDate, getSize, getTag, setCharacterSet, setExpirationDate, setIdentifier, setIdentifier, setMediaType, setModificationDate, setSize, setTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomRepresentation

public DomRepresentation(MediaType mediaType)
                  throws IOException
Constructor for an empty document.

Parameters:
mediaType - The representation's media type.
Throws:
IOException

DomRepresentation

public DomRepresentation(MediaType mediaType,
                         Document xmlDocument)
Constructor from an existing DOM document.

Parameters:
mediaType - The representation's media type.
xmlDocument - The source DOM document.

DomRepresentation

public DomRepresentation(Representation xmlRepresentation)
Constructor.

Parameters:
xmlRepresentation - A source XML representation to parse.
Method Detail

evaluate

public Object evaluate(String expression,
                       QName returnType)
                throws Exception
Description copied from class: XmlRepresentation
Evaluates an XPath expression and returns the result as in the given return type.

Specified by:
evaluate in class XmlRepresentation
returnType - The qualified name of the return type.
Returns:
The evaluation result.
Throws:
Exception
See Also:
XPathException, XPathConstants

getDocument

public Document getDocument()
                     throws IOException
Returns the wrapped DOM document.

Returns:
The wrapped DOM document.
Throws:
IOException

setDocument

public void setDocument(Document dom)
Sets the wrapped DOM document.

Parameters:
dom - The wrapped DOM document.

write

public void write(OutputStream outputStream)
           throws IOException
Writes the representation to a byte stream.

Specified by:
write in class OutputRepresentation
Parameters:
outputStream - The output stream.
Throws:
IOException


Copyright © 2005-2007 Noelios Consulting.