org.restlet.ext.xml
Class SaxRepresentation

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.SaxRepresentation
All Implemented Interfaces:
NamespaceContext
Direct Known Subclasses:
Categories, Entry, Feed, Service, TikaRepresentation, WadlRepresentation

public class SaxRepresentation
extends XmlRepresentation

XML representation for SAX events processing. The purpose is to create a streamable content based on a custom Java object model instead of a neutral DOM tree. This domain object can then be directly modified and efficiently serialized at a later time.

Subclasses only need to override the ContentHandler methods required for the reading and also the write(XmlWriter writer) method when serialization is requested.

Author:
Jerome Louvel

Field Summary
 
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
 
Constructor Summary
SaxRepresentation()
          Default constructor.
SaxRepresentation(MediaType mediaType)
          Constructor.
SaxRepresentation(MediaType mediaType, Document xmlDocument)
          Constructor.
SaxRepresentation(MediaType mediaType, InputSource xmlSource)
          Constructor.
SaxRepresentation(MediaType mediaType, SAXSource xmlSource)
          Constructor.
SaxRepresentation(Representation xmlRepresentation)
          Constructor.
 
Method Summary
 InputSource getInputSource()
          Returns the XML representation as a SAX input source.
 SAXSource getSaxSource()
          Returns the SAX source that can be parsed by the parse(ContentHandler) method or used for an XSLT transformation.
 boolean isSecureProcessing()
          Indicates if it limits potential XML overflow attacks.
 void parse(ContentHandler contentHandler)
          Parses the source and sends SAX events to a content handler.
 void release()
          Releases the namespaces map.
 void setSaxSource(SAXSource source)
          Sets a SAX source that can be parsed by the parse(ContentHandler) method.
 void setSecureProcessing(boolean secureProcessing)
          Indicates if it limits potential XML overflow attacks.
 void write(Writer writer)
           
 void write(XmlWriter writer)
          Writes the representation to a XML writer.
 
Methods inherited from class org.restlet.ext.xml.XmlRepresentation
evaluate, getBoolean, getDocument, getDocumentBuilder, getDomSource, getEntityResolver, getErrorHandler, getNamespaces, getNamespaceURI, getNode, getNodes, getNumber, getPrefix, getPrefixes, 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

SaxRepresentation

public SaxRepresentation()
Default constructor. Uses the MediaType.TEXT_XML media type.


SaxRepresentation

public SaxRepresentation(MediaType mediaType)
Constructor.

Parameters:
mediaType - The representation media type.

SaxRepresentation

public SaxRepresentation(MediaType mediaType,
                         Document xmlDocument)
Constructor.

Parameters:
mediaType - The representation's media type.
xmlDocument - A DOM document to parse.

SaxRepresentation

public SaxRepresentation(MediaType mediaType,
                         InputSource xmlSource)
Constructor.

Parameters:
mediaType - The representation's media type.
xmlSource - A SAX input source to parse.

SaxRepresentation

public SaxRepresentation(MediaType mediaType,
                         SAXSource xmlSource)
Constructor.

Parameters:
mediaType - The representation's media type.
xmlSource - A JAXP source to parse.

SaxRepresentation

public SaxRepresentation(Representation xmlRepresentation)
Constructor.

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

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

getSaxSource

public SAXSource getSaxSource()
                       throws IOException
Returns the SAX source that can be parsed by the parse(ContentHandler) method or used for an XSLT transformation.

Overrides:
getSaxSource in class XmlRepresentation
Returns:
A SAX source.
Throws:
IOException

isSecureProcessing

public boolean isSecureProcessing()
Indicates if it limits potential XML overflow attacks.

Returns:
True if it limits potential XML overflow attacks.

parse

public void parse(ContentHandler contentHandler)
           throws IOException
Parses the source and sends SAX events to a content handler.

Parameters:
contentHandler - The SAX content handler to use for parsing.
Throws:
IOException

release

public void release()
Releases the namespaces map.

Overrides:
release in class XmlRepresentation

setSaxSource

public void setSaxSource(SAXSource source)
Sets a SAX source that can be parsed by the parse(ContentHandler) method.

Parameters:
source - A SAX source.

setSecureProcessing

public void setSecureProcessing(boolean secureProcessing)
Indicates if it limits potential XML overflow attacks.

Parameters:
secureProcessing - True if it limits potential XML overflow attacks.

write

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

write

public void write(XmlWriter writer)
           throws IOException
Writes the representation to a XML writer. The default implementation calls parse(ContentHandler) using the XmlWriter parameter as the content handler. This behavior is intended to be overridden.

Parameters:
writer - The XML writer to write to.
Throws:
IOException


Copyright © 2005-2013 Restlet.