org.restlet.resource
Class SaxRepresentation

java.lang.Object
  extended by org.restlet.resource.Variant
      extended by org.restlet.resource.Representation
          extended by org.restlet.resource.StreamRepresentation
              extended by org.restlet.resource.OutputRepresentation
                  extended by org.restlet.resource.XmlRepresentation
                      extended by org.restlet.resource.SaxRepresentation
All Implemented Interfaces:
NamespaceContext

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 (contact@noelios.com)

Field Summary
 
Fields inherited from class org.restlet.resource.Variant
UNKNOWN_SIZE
 
Constructor Summary
SaxRepresentation(MediaType mediaType)
          Constructor.
SaxRepresentation(MediaType mediaType, Document xmlDocument)
          Constructor.
SaxRepresentation(Representation xmlRepresentation)
          Constructor.
 
Method Summary
 Object evaluate(String expression, QName returnType)
          Evaluates an XPath expression and returns the result as in the given return type.
 void parse(ContentHandler contentHandler)
          Parses the source and sends SAX events to a content handler.
 void write(OutputStream outputStream)
          Writes the representation to a byte stream.
 void write(XmlWriter writer)
          Writes the representation to a XML writer.
 
Methods inherited from class org.restlet.resource.XmlRepresentation
getBoolean, getNamespaceURI, getNode, getNodes, getNumber, getPrefix, getPrefixes, getText, isNamespaceAware, putNamespace, setNamespaceAware
 
Methods inherited from class org.restlet.resource.OutputRepresentation
getStream
 
Methods inherited from class org.restlet.resource.StreamRepresentation
getChannel, write
 
Methods inherited from class org.restlet.resource.Representation
getText, isAvailable, isTransient, setAvailable, setTransient
 
Methods inherited from class org.restlet.resource.Variant
getCharacterSet, getEncodings, getExpirationDate, getIdentifier, getLanguages, getMediaType, getModificationDate, getSize, getTag, setCharacterSet, setExpirationDate, setIdentifier, setIdentifier, setMediaType, setModificationDate, setSize, setTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 source DOM representation to parse.

SaxRepresentation

public SaxRepresentation(Representation xmlRepresentation)
                  throws IOException
Constructor.

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

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

write

public void write(OutputStream outputStream)
           throws IOException
Writes the representation to a byte stream.

Specified by:
write in class OutputRepresentation
Parameters:
outputStream - The output stream.
Throws:
IOException

write

public void write(XmlWriter writer)
           throws IOException
Writes the representation to a XML writer. The default implementation does nothing and is intended to be overriden.

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

evaluate

public Object evaluate(String expression,
                       QName returnType)
                throws Exception
Description copied from class: XmlRepresentation
Evaluates an XPath expression and returns the result as in the given return type.

Specified by:
evaluate in class XmlRepresentation
returnType - The qualified name of the return type.
Returns:
The evaluation result.
Throws:
Exception
See Also:
XPathException, XPathConstants


Copyright © 2005-2007 Noelios Consulting.