|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sk.uniba.euromath.gene.ExportHelper
public final class ExportHelper
Provides the context on the document level. There is exactly one instance created for each coordinator.
Field Summary | |
---|---|
(package private) XMLAccess |
doc
The document reference. |
Constructor Summary | |
---|---|
ExportHelper(XMLAccess doc)
Creates instance of the object. |
Method Summary | |
---|---|
void |
dispose()
Closes this instance, deleting all temporary files created by this instance. |
void |
disposeOfTempFile(StreamResult result)
Disposes of the temporary file. |
XMLAccess |
getDocument()
Returns the document being exported. |
String |
getExtension(String namespaceURI)
Returns the default extension for the resource. |
Messages |
getMessages()
All messages (errors occured during the export process, etc) should be stored here. |
String |
getResourceName(String name,
String namespace)
Computes the file name of given resource, including the extension. |
ContentHandler |
getSaxSerializer(OutputStream os,
String encoding,
XMLSerializerPropertiesWidget deq)
Returns the SAX serializer. |
File |
getTempFile(StreamResult result)
Returns File instance associated with given stream result
object. |
StreamResult |
newTempFile(String ext,
boolean openStream)
Creates new temporary file and returns stream pointing to that file. |
static FileOutputStream |
openStream(String file)
Tries to open the output stream onto the file. |
OutputStream |
requestResult(String fileName)
Calls coordinator's requestResult() method. |
static void |
serializeDOM(OutputStream os,
String encoding,
XMLSerializerPropertiesWidget deq,
Node node)
Serializes the document object model. |
(package private) void |
setCoordinator(ICoordinator coordinator)
Sets the underlying instance of the coordinator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
final XMLAccess doc
Constructor Detail |
---|
ExportHelper(XMLAccess doc)
doc
- the document being exportedMethod Detail |
---|
public XMLAccess getDocument()
public String getResourceName(String name, String namespace)
ResultInfo
then automatic
numbering is used.
name
- the name of the resource. May be null
- in
such case an unique name is generated automatically.namespace
- namespace of the resource, used to guess filename
extension appended to the name.
null
.public String getExtension(String namespaceURI)
namespaceURI
- the namespace identifier of the resource.
public static FileOutputStream openStream(String file) throws IOException
file
- full path to the file.
null
.
IOException
- if the file cannot be overwritten, the path cannot be
created etc.public static void serializeDOM(OutputStream os, String encoding, XMLSerializerPropertiesWidget deq, Node node) throws IOException
os
- send serialized document here.encoding
- the encoding of the document. If null
then
default is used.deq
- output format parameters. May be null
- in such
case it is ignored.node
- node to serialize.
IOException
- if serialization fails.public ContentHandler getSaxSerializer(OutputStream os, String encoding, XMLSerializerPropertiesWidget deq) throws IOException
os
- send serialized document hereencoding
- the encoding of the documentdeq
- output format parameters
IOException
- if serializer error occurs.public StreamResult newTempFile(String ext, boolean openStream) throws IOException
ext
- the extension of the file, must starting with dot. If
null
then default .tmp
extension is used.openStream
- if true
then StreamResult shall have
initialized output stream field.
StreamResult
instance.
IOException
- if temp file cannot be created.public void disposeOfTempFile(StreamResult result) throws IOException
result
- the result object denoting temporary file.
IOException
- if file cannot be closed.public File getTempFile(StreamResult result)
File
instance associated with given stream result
object.
result
- the temporary file created by this instance of helper.
File
instance or null
if given
result was not created by this helper instance.public void dispose()
public OutputStream requestResult(String fileName) throws IOException
Calls coordinator's
requestResult()
method.
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). It is caller's responsibility to close opened stream.
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.void setCoordinator(ICoordinator coordinator)
coordinator
- the coordinator instance.public Messages getMessages()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |