|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sk.uniba.euromath.gene.builtin.XHTMLCoordinator
public class XHTMLCoordinator
Implements the XHTML (http://www.w3.org/1999/xhtml
) output
class functionality.
Namespace | Name | Input kind |
http://www.w3.org/1999/xhtml | XHTML | SAXSource |
http://www.w3.org/2000/svg | SVG vector graphics | SAXSource |
http://www.w3.org/1998/Math/MathML | MathML | SAXSource |
http://www.uniba.sk/euromath/holder/png | Binary image | StreamSource |
This coordinator processes emp:mark
itself - it may be 1:1
copied by the exporter from the source document fragment. If
xhtml:img
and xhtml:a
references local
resources then these resources are copied to the export directory and these
elements are modified to hold these new (relative) references.
If exporter result of some nametree is an image then it is saved into the
export directory and the emp:mark
element is replaced by the
xhtml:img
element.
Constructor Summary | |
---|---|
XHTMLCoordinator(ExportHelper helper)
Constructs the instance of the coordinator. |
Method Summary | |
---|---|
void |
alterContext(IExporter exporter,
ExportContext context,
NamespacePath path)
May be called anytime during the export process. |
IConfigurator |
configure()
Configures the coordinator for exporting a particular document. |
void |
dispose()
Disposes of this coordinator. |
void |
finishExport()
Finalizes the export of the document. |
ExportGraphBuilder |
getGraphBuilder()
Called after the configure() method. |
ExportHelper |
getHelper()
Returns helper instance provided to the coordinator. |
(package private) static Map<String,EnumSet<SourceEnum>> |
getNamespaces()
Returns namespaces accepted. |
EnumSet<SourceEnum> |
getSource(String namespace)
Specifies the input types that the coordinator's partialResultEvent
method is able to receive from exporters. |
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. |
OutputStream |
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(URLDir root,
String fileName,
String 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 |
---|
public XHTMLCoordinator(ExportHelper helper)
helper
- the export helper instanceMethod Detail |
---|
public IConfigurator configure()
ICoordinator
configure
in interface ICoordinator
null
if the coordinator
does not need to be configured.public void dispose()
ICoordinator
dispose
in interface ICoordinator
public ExportHelper getHelper()
ICoordinator
getHelper
in interface ICoordinator
public ExportGraphBuilder getGraphBuilder()
ICoordinator
configure()
method. Returns configured
instance of the graph builder.
getGraphBuilder
in interface ICoordinator
null
-
in such case the getTransformationChain()
is used to
determine the exporter graph.public TransformGraph getTransformationGraph()
ICoordinator
getGraphBuilder()
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 ICoordinator
null
then the exporting process fails.public Source partialResultEvent(DocumentFragment processed, NamespacePath path, Source source, String sourceNamespace, CoordinatorInputKey key) throws ExportException, IOException
ICoordinator
null
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 ICoordinator
processed
- 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 OutputStream requestResult(String fileName) throws IOException
ICoordinator
requestResult
in interface ICoordinator
fileName
- 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
.
IOException
- if i/o error occurs.public Result startExport(URLDir root, String fileName, String systemId) throws ExportException, IOException
ICoordinator
Initiates 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 ICoordinator
root
- the directory where the file will be exported. 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).fileName
- the name of the primary file being exported.systemId
- system identifier of the primary output file, constructed
from root
and fileName
parameters for
convenience. A OS-dependent identifier, suitable to be passed to
File
object.
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 finishExport() throws ExportException, IOException
ICoordinator
finishExport
in interface ICoordinator
ExportException
- if something goes wrong
IOException
- if i/o error occurs.public EnumSet<SourceEnum> getSource(String namespace)
ICoordinator
Specifies the input types that the coordinator's
partialResultEvent
method is able to receive from exporters. If it accepts multiple types
then the output with highest priority is picked.
ObjectSource
has the highest priority, followed by SAX,
DOM and Stream.
Warning: this method result must be consistent with result returned by
the CoordinatorInfo
object instance for this coordinator
class!
getSource
in interface ICoordinator
namespace
- the namespace of the fragment that this coordinator may
receive.
null
if coordinator does not accept fragments with given
namespace.static Map<String,EnumSet<SourceEnum>> getNamespaces()
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 ICoordinator
namespace
- the namespace that communicates using the Object
source/result kind.
null
.public void alterContext(IExporter exporter, ExportContext context, NamespacePath path)
ICoordinator
May be called 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 ICoordinator
exporter
- 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 |