Package org.restlet.ext.xml
Class DomRepresentation
- java.lang.Object
-
- org.restlet.representation.Variant
-
- org.restlet.representation.RepresentationInfo
-
- org.restlet.representation.Representation
-
- org.restlet.representation.CharacterRepresentation
-
- org.restlet.representation.WriterRepresentation
-
- org.restlet.ext.xml.XmlRepresentation
-
- org.restlet.ext.xml.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
-
-
Field Summary
-
Fields inherited from class org.restlet.ext.xml.XmlRepresentation
XML_EXPANDING_ENTITY_REFS, XML_VALIDATING_DTD
-
-
Constructor Summary
Constructors Constructor Description DomRepresentation()
Default constructor.DomRepresentation(org.restlet.data.MediaType mediaType)
Constructor for an empty document.DomRepresentation(org.restlet.data.MediaType mediaType, org.w3c.dom.Document xmlDocument)
Constructor from an existing DOM document.DomRepresentation(org.restlet.representation.Representation xmlRepresentation)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.Document
getDocument()
Returns the wrapped DOM document.org.xml.sax.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(org.w3c.dom.Document dom)
Sets the wrapped DOM document.void
setIndenting(boolean indenting)
Indicates if the XML serialization should be indented.void
write(java.io.Writer writer)
-
Methods inherited from class org.restlet.ext.xml.XmlRepresentation
getDocumentBuilder, getEntityResolver, getErrorHandler, getNamespaces, getNamespaceURI, getPrefix, getPrefixes, getTextContent, isCoalescing, isExpandingEntityRefs, isIgnoringComments, isIgnoringExtraWhitespaces, isNamespaceAware, isValidatingDtd, isXIncludeAware, setCoalescing, setEntityResolver, setErrorHandler, setExpandingEntityRefs, setIgnoringComments, setIgnoringExtraWhitespaces, setNamespaceAware, setNamespaces, setValidatingDtd, setXIncludeAware
-
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
-
-
-
-
Constructor Detail
-
DomRepresentation
public DomRepresentation() throws java.io.IOException
Default constructor. Uses theMediaType.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 classXmlRepresentation
- 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 classXmlRepresentation
- 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 classXmlRepresentation
-
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 classorg.restlet.representation.Representation
- Throws:
java.io.IOException
-
-