net.sf.saxon.serialize
Class Emitter

java.lang.Object
  extended by net.sf.saxon.serialize.Emitter
All Implemented Interfaces:
Result, Receiver
Direct Known Subclasses:
BinaryEmitter, PTreeEmitter, XMLEmitter

public abstract class Emitter
extends Object
implements Result, Receiver

Emitter: This abstract class defines methods that must be implemented by components that format SAXON output. There is one emitter for XML, one for HTML, and so on. Additional methods are concerned with setting options and providing a Writer.

The interface is deliberately designed to be as close as possible to the standard SAX2 ContentHandler interface, however, it allows additional information to be made available. An Emitter is a Receiver, specifically it is a Receiver that can direct output to a Writer or OutputStream, using serialization properties defined in a Properties object.


Field Summary
protected  boolean allCharactersEncodable
           
protected  CharacterSet characterSet
           
protected  NamePool namePool
           
protected  Properties outputProperties
           
protected  OutputStream outputStream
           
protected  PipelineConfiguration pipelineConfig
           
protected  StreamResult streamResult
           
protected  String systemId
           
protected  Writer writer
           
 
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
 
Constructor Summary
Emitter()
           
 
Method Summary
 void close()
          Notify the end of the event stream
 Configuration getConfiguration()
          Get the configuration used for this document
 Properties getOutputProperties()
          Get the output properties
 OutputStream getOutputStream()
          Get the output stream
 PipelineConfiguration getPipelineConfiguration()
          Get the pipeline configuration used for this document
 String getSystemId()
          Get the System ID
 Writer getWriter()
          Get the output writer
protected  OutputStream makeOutputStream()
           
protected  void makeWriter()
          Make a Writer for this Emitter to use, given a StreamResult.
 void setOutputProperties(Properties details)
          Set output properties
 void setOutputStream(OutputStream stream)
          Set the output destination as a byte stream.
 void setPipelineConfiguration(PipelineConfiguration pipe)
          Set the pipelineConfiguration
 void setStreamResult(StreamResult result)
          Set the StreamResult acting as the output destination of the Emitter
 void setSystemId(String systemId)
          Set the System ID
 void setUnparsedEntity(String name, String uri, String publicId)
          Set unparsed entity URI.
 void setWriter(Writer writer)
          Set the output destination as a character stream
 boolean usesWriter()
          Determine whether the Emitter wants a Writer for character output or an OutputStream for binary output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.event.Receiver
attribute, characters, comment, endDocument, endElement, namespace, open, processingInstruction, startContent, startDocument, startElement, usesTypeAnnotations
 

Field Detail

pipelineConfig

protected PipelineConfiguration pipelineConfig

namePool

protected NamePool namePool

systemId

protected String systemId

streamResult

protected StreamResult streamResult

writer

protected Writer writer

outputStream

protected OutputStream outputStream

outputProperties

protected Properties outputProperties

characterSet

protected CharacterSet characterSet

allCharactersEncodable

protected boolean allCharactersEncodable
Constructor Detail

Emitter

public Emitter()
Method Detail

setPipelineConfiguration

public void setPipelineConfiguration(PipelineConfiguration pipe)
Set the pipelineConfiguration

Specified by:
setPipelineConfiguration in interface Receiver
Parameters:
pipe - the pipeline configuration

getPipelineConfiguration

public PipelineConfiguration getPipelineConfiguration()
Get the pipeline configuration used for this document

Specified by:
getPipelineConfiguration in interface Receiver
Returns:
the pipeline configuration

getConfiguration

public Configuration getConfiguration()
Get the configuration used for this document

Returns:
the configuration

setSystemId

public void setSystemId(String systemId)
Set the System ID

Specified by:
setSystemId in interface Result
Specified by:
setSystemId in interface Receiver
Parameters:
systemId - the system identifier (=base URI)

getSystemId

public String getSystemId()
Get the System ID

Specified by:
getSystemId in interface Result

setOutputProperties

public void setOutputProperties(Properties details)
                         throws XPathException
Set output properties

Parameters:
details - the output serialization properties
Throws:
XPathException

getOutputProperties

public Properties getOutputProperties()
Get the output properties

Returns:
the output serialization properties. The returned value will be null if setOutputProperties() has not been called

setStreamResult

public void setStreamResult(StreamResult result)
                     throws XPathException
Set the StreamResult acting as the output destination of the Emitter

Parameters:
result - the output destination
Throws:
XPathException

makeWriter

protected void makeWriter()
                   throws XPathException
Make a Writer for this Emitter to use, given a StreamResult.

Throws:
XPathException

makeOutputStream

protected OutputStream makeOutputStream()
                                 throws XPathException
Throws:
XPathException

usesWriter

public boolean usesWriter()
Determine whether the Emitter wants a Writer for character output or an OutputStream for binary output. The standard Emitters all use a Writer, so this returns true; but a subclass can override this if it wants to use an OutputStream

Returns:
true if a Writer is needed, as distinct from an OutputStream

setWriter

public void setWriter(Writer writer)
               throws XPathException
Set the output destination as a character stream

Parameters:
writer - the Writer to use as an output destination
Throws:
XPathException

getWriter

public Writer getWriter()
Get the output writer

Returns:
the Writer being used as an output destination, if any

setOutputStream

public void setOutputStream(OutputStream stream)
                     throws XPathException
Set the output destination as a byte stream.

Note that if a specific encoding (other than the default, UTF-8) is required, then setOutputProperties(java.util.Properties) must be called before calling this method.

Parameters:
stream - the OutputStream being used as an output destination
Throws:
XPathException

getOutputStream

public OutputStream getOutputStream()
Get the output stream

Returns:
the OutputStream being used as an output destination, if any

setUnparsedEntity

public void setUnparsedEntity(String name,
                              String uri,
                              String publicId)
                       throws XPathException
Set unparsed entity URI. Needed to satisfy the Receiver interface, but not used, because unparsed entities can occur only in input documents, not in output documents.

Specified by:
setUnparsedEntity in interface Receiver
Parameters:
name - the entity name
uri - the entity system ID
publicId - the entity public ID
Throws:
XPathException

close

public void close()
           throws XPathException
Notify the end of the event stream

Specified by:
close in interface Receiver
Throws:
XPathException


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.