Class AbstractXMLWriter
java.lang.Object
de.uni_trier.wi2.procake.utils.composition.FactoryObjectImplementation
de.uni_trier.wi2.procake.data.io.IOImpl
de.uni_trier.wi2.procake.data.io.xml.xerces_writerImpl.AbstractXMLWriter
- All Implemented Interfaces:
IO
,ProCAKEWriter
- Direct Known Subclasses:
DependencyWriter
,ModelWriter
,ObjectPoolWriter
,ObjectWriter
,SimilarityModelWriter
,TrainingPoolWriter
,WorkflowGraphMLYWriter
,WorkflowWriter
Abstract class for code reuse. All ProCAKEWriter-implementations do have several features in common.
- Author:
- Alexander Stromer
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
Name of the XML-file to write into.protected OutputStream
Output stream to write into.Fields inherited from interface de.uni_trier.wi2.procake.utils.io.IO
DEFAULT_ENCODING, LOG_FILE_NOT_FOUND, LOG_IO_EXCEPTION, LOG_READER_NOT_FOUND, LOG_SAX_EXCEPTION, LOG_UNKNOWN_PARAMETER, LOG_WRONG_PARAMATER_TYPE, RESOURCE_XML
Fields inherited from interface de.uni_trier.wi2.procake.utils.io.ProCAKEWriter
LOG_CANNOT_WRITE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected GenericXMLSchemaBasedWriter
Based on the setting of filename and output stream an output mode is chosen.abstract void
Adds the namespace-imports of this handler to the given xmlWriter.void
setFilename
(String filename) Each writer must be able to write a file to the local filesystem.void
setOutputStream
(OutputStream output) Each writer must be able to store the object into an OutputStream.void
The store command writes the given value.abstract void
store
(Object value, GenericXMLSchemaBasedWriter writer) To embed xml writers into another one it must be possible to specify the parentGenericXMLSchemaBasedWriter
as well as a prefix that should be probably used.protected void
storeWithFamiliarWriter
(Object value, GenericXMLSchemaBasedWriter writer) Tries to write the given object, with a familiar writer-implementation AND using the already instantiated writer-objectMethods inherited from class de.uni_trier.wi2.procake.data.io.IOImpl
getFamily, getParameters, postInit, preInit, setFamily
Methods inherited from class de.uni_trier.wi2.procake.utils.composition.FactoryObjectImplementation
getParameter, initParametersBasedOn
-
Field Details
-
filename
Name of the XML-file to write into. -
outputStream
Output stream to write into.
-
-
Constructor Details
-
AbstractXMLWriter
public AbstractXMLWriter()
-
-
Method Details
-
setFilename
Each writer must be able to write a file to the local filesystem. The filename should be an absolute path.- Specified by:
setFilename
in interfaceProCAKEWriter
- Parameters:
filename
- The filename into which the object should be stored.
-
setOutputStream
Each writer must be able to store the object into an OutputStream.- Specified by:
setOutputStream
in interfaceProCAKEWriter
- Parameters:
output
- TheOutputStream
into that the object should be stored.
-
createXMLWriter
Based on the setting of filename and output stream an output mode is chosen. If a filename exists, the output goes to the file. If not the output stream is used.- Returns:
- The XMLWriter representing the file or output stream.
- Throws:
IOException
-
store
The store command writes the given value.- Specified by:
store
in interfaceProCAKEWriter
- Parameters:
value
- The object that should be stored- Throws:
CAKEIOException
-
insertNamespace
Adds the namespace-imports of this handler to the given xmlWriter.- Parameters:
writer
- aGenericXMLSchemaBasedWriter
object
-
store
To embed xml writers into another one it must be possible to specify the parentGenericXMLSchemaBasedWriter
as well as a prefix that should be probably used. If a parent writer is specified, no header will be written.If the writer does not support XML writing, the writer should throw an
UnsupportedOperationException
.public void store(Object value, String prefix, XMLWriter writer) throws CakeIOException { throw new UnsupportedOperationException(); }
- Parameters:
writer
- A parent writer that is used.value
- aObject
object- Throws:
CAKEIOException
- if any.
-
storeWithFamiliarWriter
protected void storeWithFamiliarWriter(Object value, GenericXMLSchemaBasedWriter writer) throws IOException, CAKEIOException Tries to write the given object, with a familiar writer-implementation AND using the already instantiated writer-object- Parameters:
value
- aObject
objectwriter
- aGenericXMLSchemaBasedWriter
object- Throws:
IOException
CAKEIOException
-