net.sf.saxon.event
Class Emitter

java.lang.Object
  extended by net.sf.saxon.event.Emitter
All Implemented Interfaces:
Result, Receiver
Direct Known Subclasses:
ContentHandlerProxy, DOMEmitter, UncommittedEmitter, 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  CharacterSet characterSet
           
protected  Locator locator
           
protected  NamePool namePool
           
protected  Properties outputProperties
           
protected  OutputStream outputStream
           
protected  StreamResult streamResult
           
protected  String systemId
           
protected  Writer writer
           
 
Constructor Summary
Emitter()
           
 
Method Summary
 NamePool getNamePool()
          Get the namepool used for this document
 Properties getOutputProperties()
          Get the output properties
 OutputStream getOutputStream()
          Get the output stream
 String getSystemId()
          Get the System ID
 Writer getWriter()
          Get the output writer
static Emitter makeEmitter(String className)
          Load a named output emitter or SAX2 ContentHandler and check it is OK.
protected  void makeWriter()
          Make a Writer for this Emitter to use, given a StreamResult
 void setDocumentLocator(Locator locator)
          Set locator, to identify position in the document.
 void setNamePool(NamePool namePool)
          Set the namePool in which all name codes can be found
 void setOutputProperties(Properties details)
          Set output properties
 void setOutputStream(OutputStream stream)
          Set the output destination as a byte stream
 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, processingInstruction, startContent, startDocument, startElement
 

Field Detail

namePool

protected NamePool namePool

systemId

protected String systemId

streamResult

protected StreamResult streamResult

writer

protected Writer writer

outputStream

protected OutputStream outputStream

outputProperties

protected Properties outputProperties

locator

protected Locator locator

characterSet

protected CharacterSet characterSet
Constructor Detail

Emitter

public Emitter()
Method Detail

setNamePool

public void setNamePool(NamePool namePool)
Set the namePool in which all name codes can be found

Specified by:
setNamePool in interface Receiver

getNamePool

public NamePool getNamePool()
Get the namepool used for this document

Specified by:
getNamePool in interface Receiver

setSystemId

public void setSystemId(String systemId)
Set the System ID

Specified by:
setSystemId in interface Result
Specified by:
setSystemId in interface Receiver

getSystemId

public String getSystemId()
Get the System ID

Specified by:
getSystemId in interface Result

setOutputProperties

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

Throws:
TransformerException

getOutputProperties

public Properties getOutputProperties()
Get the output properties


setStreamResult

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


makeWriter

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

Throws:
TransformerException

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


setWriter

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


getWriter

public Writer getWriter()
Get the output writer


setOutputStream

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

Throws:
TransformerException

getOutputStream

public OutputStream getOutputStream()
Get the output stream


setDocumentLocator

public void setDocumentLocator(Locator locator)
Set locator, to identify position in the document. Used only when supplying input from a parser.

Specified by:
setDocumentLocator in interface Receiver

setUnparsedEntity

public void setUnparsedEntity(String name,
                              String uri,
                              String publicId)
                       throws TransformerException
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 name of the unparsed entity
uri - The system identifier of the unparsed entity
publicId - The public identifier of the unparsed entity
Throws:
TransformerException

makeEmitter

public static Emitter makeEmitter(String className)
                           throws TransformerException
Load a named output emitter or SAX2 ContentHandler and check it is OK.

Throws:
TransformerException