Class DomRepresentation


  • 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
    • Constructor Detail

      • DomRepresentation

        public DomRepresentation()
                          throws java.io.IOException
        Default constructor. Uses the MediaType.TEXT_XML media type.
        Throws:
        java.io.IOException
      • DomRepresentation

        public DomRepresentation​(org.restlet.data.MediaType mediaType)
                          throws java.io.IOException
        Constructor for an empty document.
        Parameters:
        mediaType - The representation's media type.
        Throws:
        java.io.IOException
      • DomRepresentation

        public DomRepresentation​(org.restlet.data.MediaType mediaType,
                                 org.w3c.dom.Document xmlDocument)
        Constructor from an existing DOM document.
        Parameters:
        mediaType - The representation's media type.
        xmlDocument - The source DOM document.
      • DomRepresentation

        public DomRepresentation​(org.restlet.representation.Representation xmlRepresentation)
        Constructor.
        Parameters:
        xmlRepresentation - A source XML representation to parse.
    • Method Detail

      • getDocument

        public org.w3c.dom.Document getDocument()
                                         throws java.io.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:
        java.io.IOException
      • getInputSource

        public org.xml.sax.InputSource getInputSource()
                                               throws java.io.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:
        java.io.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​(org.w3c.dom.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​(java.io.Writer writer)
                   throws java.io.IOException
        Specified by:
        write in class org.restlet.representation.Representation
        Throws:
        java.io.IOException