Class Emitter
java.lang.Object
net.sf.saxon.serialize.Emitter
- Direct Known Subclasses:
XMLEmitter
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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected CharacterSetprotected NamePoolprotected Propertiesprotected OutputStreamprotected PipelineConfigurationprotected StreamResultprotected Stringprotected WriterFields inherited from interface Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Notify the end of the event streamGet the configuration used for this documentGet the output propertiesGet the output streamGet the pipeline configuration used for this documentGet the System IDGet the output writerprotected OutputStreamprotected voidMake a Writer for this Emitter to use, given a StreamResult.voidsetOutputProperties(Properties details) Set output propertiesvoidsetOutputStream(OutputStream stream) Set the output destination as a byte stream.voidSet the pipelineConfigurationvoidsetStreamResult(StreamResult result) Set the StreamResult acting as the output destination of the EmittervoidsetSystemId(String systemId) Set the System IDvoidsetUnparsedEntity(String name, String uri, String publicId) Set unparsed entity URI.voidSet the output destination as a character streambooleanAsk whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute eventsbooleanDetermine whether the Emitter wants a Writer for character output or an OutputStream for binary output.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Receiver
attribute, characters, comment, endDocument, endElement, namespace, open, processingInstruction, startContent, startDocument, startElement
-
Field Details
-
pipelineConfig
-
namePool
-
systemId
-
streamResult
-
writer
-
outputStream
-
outputProperties
-
characterSet
-
allCharactersEncodable
protected boolean allCharactersEncodable
-
-
Constructor Details
-
Emitter
public Emitter()
-
-
Method Details
-
setPipelineConfiguration
Set the pipelineConfiguration- Specified by:
setPipelineConfigurationin interfaceReceiver- Parameters:
pipe- the pipeline configuration
-
getPipelineConfiguration
Get the pipeline configuration used for this document- Specified by:
getPipelineConfigurationin interfaceReceiver- Returns:
- the pipeline configuration
-
getConfiguration
Get the configuration used for this document- Returns:
- the configuration
-
setSystemId
Set the System ID- Specified by:
setSystemIdin interfaceReceiver- Specified by:
setSystemIdin interfaceResult- Parameters:
systemId- the system identifier (=base URI)
-
getSystemId
-
setOutputProperties
Set output properties- Parameters:
details- the output serialization properties- Throws:
XPathException- if an error occurs finding the encoding property
-
getOutputProperties
Get the output properties- Returns:
- the output serialization properties. The returned value will be null if setOutputProperties() has not been called
-
setStreamResult
Set the StreamResult acting as the output destination of the Emitter- Parameters:
result- the output destination- Throws:
XPathException- if an error occurs
-
makeWriter
Make a Writer for this Emitter to use, given a StreamResult.- Throws:
XPathException- if an error occurs
-
makeOutputStream
- 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
Set the output destination as a character stream- Parameters:
writer- the Writer to use as an output destination- Throws:
XPathException- if an error occurs
-
getWriter
Get the output writer- Returns:
- the Writer being used as an output destination, if any
-
setOutputStream
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- if an error occurs
-
getOutputStream
Get the output stream- Returns:
- the OutputStream being used as an output destination, if any
-
setUnparsedEntity
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:
setUnparsedEntityin interfaceReceiver- Parameters:
name- the entity nameuri- the entity system IDpublicId- the entity public ID- Throws:
XPathException- if an error occurs
-
close
Notify the end of the event stream- Specified by:
closein interfaceReceiver- Throws:
XPathException- if an error occurs
-
usesTypeAnnotations
public boolean usesTypeAnnotations()Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute events- Specified by:
usesTypeAnnotationsin interfaceReceiver- Returns:
- true if the Receiver makes any use of this information. If false, the caller may supply untyped nodes instead of supplying the type annotation (or conversely, it may avoid stripping unwanted type annotations)
-