org.restlet.ext.xml
Class DomRepresentation

java.lang.Object
  extended by org.restlet.representation.Variant
      extended by org.restlet.representation.RepresentationInfo
          extended by org.restlet.representation.Representation
              extended by org.restlet.representation.CharacterRepresentation
                  extended by org.restlet.representation.WriterRepresentation
                      extended by org.restlet.ext.xml.XmlRepresentation
                          extended by org.restlet.ext.xml.DomRepresentation
All Implemented Interfaces:
NamespaceContext
Direct Known Subclasses:
MessageRepresentation, MessagesRepresentation

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

Field Summary
 
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
 
Constructor Summary
DomRepresentation()
          Default constructor.
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
protected  Transformer createTransformer()
          Creates a new JAXP Transformer object that will be used to serialize this DOM.
 Document getDocument()
          Returns the wrapped DOM document.
 DOMSource getDomSource()
          Returns a DOM source.
 InputSource getInputSource()
          Returns the XML representation as a SAX input source.
 boolean isIndenting()
          Indicates if the XML serialization should be indented.
 void release()
          Releases the wrapped DOM document and the source XML representation if they have been defined.
 void setDocument(Document dom)
          Sets the wrapped DOM document.
 void setIndenting(boolean indenting)
          Indicates if the XML serialization should be indented.
 void write(Writer writer)
           
 
Methods inherited from class org.restlet.ext.xml.XmlRepresentation
evaluate, getBoolean, getDocumentBuilder, getEntityResolver, getErrorHandler, getNamespaces, getNamespaceURI, getNode, getNodes, getNumber, getPrefix, getPrefixes, getSaxSource, getSaxSource, getSchema, getStreamSource, getText, isCoalescing, isExpandingEntityRefs, isIgnoringComments, isIgnoringExtraWhitespaces, isNamespaceAware, isValidatingDtd, isXIncludeAware, setCoalescing, setEntityResolver, setErrorHandler, setExpandingEntityRefs, setIgnoringComments, setIgnoringExtraWhitespaces, setNamespaceAware, setNamespaces, setSchema, setSchema, setValidatingDtd, setXIncludeAware, validate, validate, validate, validate
 
Methods inherited from class org.restlet.representation.WriterRepresentation
getReader
 
Methods inherited from class org.restlet.representation.CharacterRepresentation
getChannel, getStream, write, write
 
Methods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
 
Methods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTag
 
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DomRepresentation

public DomRepresentation()
                  throws IOException
Default constructor. Uses the MediaType.TEXT_XML media type.

Throws:
IOException

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

createTransformer

protected Transformer createTransformer()
                                 throws IOException
Creates a new JAXP Transformer object that will be used to serialize this DOM. This method may be overridden in order to set custom properties on the Transformer.

Returns:
The transformer to be used for serialization.
Throws:
IOException

getDocument

public Document getDocument()
                     throws IOException
Returns the wrapped DOM document. If no document is defined yet, it attempts to parse the XML representation eventually given at construction time. Otherwise, it just creates a new document.

Overrides:
getDocument in class XmlRepresentation
Returns:
The wrapped DOM document.
Throws:
IOException

getDomSource

public DOMSource getDomSource()
                       throws IOException
Returns a DOM source.

Overrides:
getDomSource in class XmlRepresentation
Returns:
A DOM source.
Throws:
IOException

getInputSource

public InputSource getInputSource()
                           throws IOException
Description copied from class: XmlRepresentation
Returns the XML representation as a SAX input source.

Specified by:
getInputSource in class XmlRepresentation
Returns:
The SAX input source.
Throws:
IOException

isIndenting

public boolean isIndenting()
Indicates if the XML serialization should be indented. False by default.

Returns:
True if the XML serialization should be indented.

release

public void release()
Releases the wrapped DOM document and the source XML representation if they have been defined.

Overrides:
release in class XmlRepresentation

setDocument

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

Parameters:
dom - The wrapped DOM document.

setIndenting

public void setIndenting(boolean indenting)
Indicates if the XML serialization should be indented.

Parameters:
indenting - True if the XML serialization should be indented.

write

public void write(Writer writer)
           throws IOException
Specified by:
write in class Representation
Throws:
IOException


Copyright © 2005-2013 Restlet.