|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.xml.gene.builtin.LaTeXCoordinator
public class LaTeXCoordinator
Implements the LaTeX output class functionality.
Since the LaTeX format is a character stream format all exporters general
output should be a character stream. However, the result requested from the
exporters is not StreamResult- the SAXResult
is used instead. That is because the exporter can emit the
emp:mark element. The element is used to mark entrypoints to
nametree with another namespace - it should be a simple 1:1 copy from source
document fragment.
The coordinator thus expects the
http://www.uniba.sk/euromath/holder/latex and
http://www.uniba.sk/euromath/holder/eps namespaces transmitted
via SAXSource. Coordinator produces LaTeX StreamOutput.
None.
| Constructor Summary | |
|---|---|
LaTeXCoordinator(CoordinatorInfo info)
Constructs the instance of the coordinator. |
|
| Method Summary | |
|---|---|
void |
alterContext(IExporter exporter,
ExportContext context,
NamespacePath path)
Called by GENE core anytime during the export process. |
void |
dispose()
Disposes of this coordinator. |
void |
finishExport()
Finalizes the export of the document. |
IConfigurator |
getConfigurator()
Configures the coordinator for exporting a particular document. |
ExportGraphBuilder |
getGraphBuilder()
Called after the configure() method. |
CoordinatorInfo |
getInfo()
Returns the coordinator info instance that describes this coordinator. |
(package private) static Map<String,EnumSet<SourceEnum>> |
getNamespaces()
Returns namespaces accepted. |
TransformGraph |
getTransformationGraph()
Called only if getGraphBuilder() returned
null. |
Object |
offerObject(String namespace)
When the coordinator accepts the ObjectSource but wants to provide an object as a result to the exporter E (for example it wants E to draw something in a certain instance of Graphics), then return non-null value. |
Source |
partialResultEvent(DocumentFragment processed,
NamespacePath path,
Source source,
String sourceNamespace,
CoordinatorInputKey key)
Using this method the coordinator is queried if it wants to modify the final result of one exporter pipe. |
StreamResult |
requestResult(String fileName)
May be used when exporter wishes to write additional files as its output (an image that is referenced by XML produced by the exporter for example). |
Result |
startExport(File systemId)
Initiates the export itself. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
LaTeXCoordinator(CoordinatorInfo info)
info - the info.| Method Detail |
|---|
public IConfigurator getConfigurator()
ICoordinator
getConfigurator in interface ICoordinatornull if the coordinator
does not need to be configured.public CoordinatorInfo getInfo()
ICoordinator
getInfo in interface ICoordinatornull.public ExportGraphBuilder getGraphBuilder()
ICoordinatorconfigure() method. Returns configured
instance of the graph builder.
getGraphBuilder in interface ICoordinatornull -
in such case the getTransformationChain() is used to
determine the exporter graph.public TransformGraph getTransformationGraph()
ICoordinatorgetGraphBuilder() returned
null. Describes the exporter graph directly. Returns
non-empty map that maps each namespace present in the document to a
TransformationInfo instance describing exporter chain
exporting the namespace.
getTransformationGraph in interface ICoordinatornull
then the exporting process fails.static Map<String,EnumSet<SourceEnum>> getNamespaces()
public void finishExport()
throws ExportException,
IOException
ICoordinator
finishExport in interface ICoordinatorExportException - if something goes wrong
IOException - if i/o error occurs.
public Result startExport(File systemId)
throws ExportException,
IOException
ICoordinatorInitiates the export itself. Coordinator must return a result where exporters results are written.
Coordinator is responsible to convert exporter's output (in the
partialResultEvent() method) to Source
instance compatible with the result object returned by this method.
Failure to do so results in an ExportException during the
export. Some kinds of sources can be converted automatically; for
reference please see
SourceEnum's convert method.
startExport in interface ICoordinatorsystemId - system-dependent identifier of the primary output file.
Absolute system-dependent path with filename, suitable to be passed to
File object. Here the primary result (PDF file, HTML file,
whatever) will be stored. Coordinator may create additional directories
and files whenever needed (for example png/jpg images referenced by the
primary html file etc).
emp:mark elements
are replaced by transformation results. DOM source is given as a DOM node
containing the whole document, SAX source gives result on-the-fly.
ExportException - if something goes wrong
IOException - if i/o error occurs.public void dispose()
ICoordinator
dispose in interface ICoordinator
public Source partialResultEvent(DocumentFragment processed,
NamespacePath path,
Source source,
String sourceNamespace,
CoordinatorInputKey key)
throws ExportException,
IOException
ICoordinatornull
value must be returned - this Source object shall be used as a
replacement of the result. The source parameter (or the result of the
method if non-null) is then stored into memory. When all exporters
finish, these stored pieces are put together and finally transmitted to
the coordinator again using the export() call.
partialResultEvent in interface ICoordinatorprocessed - this document fragment is being processed and the Result
holds part (or whole) result of the fragment processing.path - the namespace path to the parent product.source - contains the result of a nametree processing. If the
systemId is not null then it is a system-dependent local
filesystem path to a file that holds the content of this result. Warning:
instance of SAXSource is a live instance - if you call parse on the
XMLReader instance then it reads the whole result. If this result is not
stored and returned in a Source then it is lost. You may convert it to
the DOMSource, make necessary adjustments and then convert back to the
SAXSource and return. You may also construct new XMLReader (reading from
the old source and making adjustments on-the-fly) and return it.sourceNamespace - the namespace of the source.key - uniquely identifies the pipe from exporter to the coordinator.
null then returned source is put into the 'big
picture' as-is. If not null then the content of the source
is ignored and the returned Source instance is used instead.
ExportException - if error occurs during the source processing
IOException - if error occurs during reading the source.
public StreamResult requestResult(String fileName)
throws IOException
ICoordinatorMay be used when exporter wishes to write additional files as its output (an image that is referenced by XML produced by the exporter for example). It is caller's responsibility to close opened stream.
The coordinator should create a good-looking directory structure when the
exported format contains images visible on the filesystem. For example,
XHTML exporter should put all files into the
exportedFileName-images directory. If exporting
format embeds the images (PDF, TIFF) then the coordinator may just create
a temp file and return an outputstream to it.
requestResult in interface ICoordinatorfileName - the name of the file being created. The coordinator may
ignore the filename if it is not part of the result file (for example
when a PNG image is embedded in result PDF file). Coordinator may change
the filename if a file with this name already exists. If
null or empty string, coordinator may generate any name.
null result containing non-null
opened output stream and null writer. The
Result.getSystemId() must contain filename relative to the
location of the document being exported.
IOException - if i/o error occurs.public Object offerObject(String namespace)
ICoordinator
When the coordinator accepts the ObjectSource but wants to provide an
object as a result to the exporter E (for example it wants E to draw
something in a certain instance of Graphics), then return non-null value.
If this functionality is not needed then just return null -
if E requires some object then it can create any object as long as it is
instance of class that this exporter expects.
The consumer (the one that receives the object, i.e. this) is responsible
for freeing the object if necessary (at the end of the export method),
even if this function returned null.
If you want producer (the one that creates the object) to create custom
instances then provide a factory object. This trick is used with
http://www.uniba.sk/euromath/holder/java.awt.Graphics
holder - a factory is returned that is able to produce
java.awt.Graphics instances.
offerObject in interface ICoordinatornamespace - the namespace that communicates using the Object
source/result kind.
null.
public void alterContext(IExporter exporter,
ExportContext context,
NamespacePath path)
ICoordinatorCalled by GENE core anytime during the export process. By modifying given context values the coordinator may force the GENE engine to report another context to an exporter.
If you don't want to override GENE default behaviour just use an empty implementation.
alterContext in interface ICoordinatorexporter - this exporter is about to be executed with given context
object. Never null. The coordinator must NOT call the
IExporter.export(Source, Result, ExportContext) method.context - current context object. Never null.path - current namespace path. It must NOT be altered. Never
null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||