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.DocumentgetDocument()Returns the wrapped DOM document.org.xml.sax.InputSourcegetInputSource()Returns the XML representation as a SAX input source.booleanisIndenting()Indicates if the XML serialization should be indented.voidrelease()Releases the wrapped DOM document and the source XML representation if they have been defined.voidsetDocument(org.w3c.dom.Document dom)Sets the wrapped DOM document.voidsetIndenting(boolean indenting)Indicates if the XML serialization should be indented.voidwrite(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.IOExceptionDefault constructor. Uses theMediaType.TEXT_XMLmedia type.- Throws:
java.io.IOException
-
DomRepresentation
public DomRepresentation(org.restlet.data.MediaType mediaType) throws java.io.IOExceptionConstructor 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.IOExceptionReturns 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:
getDocumentin classXmlRepresentation- Returns:
- The wrapped DOM document.
- Throws:
java.io.IOException
-
getInputSource
public org.xml.sax.InputSource getInputSource() throws java.io.IOExceptionDescription copied from class:XmlRepresentationReturns the XML representation as a SAX input source.- Specified by:
getInputSourcein 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:
releasein 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:
writein classorg.restlet.representation.Representation- Throws:
java.io.IOException
-
-