All Implemented Interfaces:
IO, ProCAKEWriter
Direct Known Subclasses:
DependencyWriter, ModelWriter, ObjectPoolWriter, ObjectWriter, SimilarityModelWriter, TrainingPoolWriter, WorkflowGraphMLYWriter, WorkflowWriter

public abstract class AbstractXMLWriter extends IOImpl implements ProCAKEWriter
Abstract class for code reuse. All ProCAKEWriter-implementations do have several features in common.
Author:
Alexander Stromer
  • Field Details

    • filename

      protected String filename
      Name of the XML-file to write into.
    • outputStream

      protected OutputStream outputStream
      Output stream to write into.
  • Constructor Details

    • AbstractXMLWriter

      public AbstractXMLWriter()
  • Method Details

    • setFilename

      public void setFilename(String filename)
      Each writer must be able to write a file to the local filesystem. The filename should be an absolute path.
      Specified by:
      setFilename in interface ProCAKEWriter
      Parameters:
      filename - The filename into which the object should be stored.
    • setOutputStream

      public void setOutputStream(OutputStream output)
      Each writer must be able to store the object into an OutputStream.
      Specified by:
      setOutputStream in interface ProCAKEWriter
      Parameters:
      output - The OutputStream into that the object should be stored.
    • createXMLWriter

      protected GenericXMLSchemaBasedWriter createXMLWriter() throws IOException
      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

      public void store(Object value) throws CAKEIOException
      The store command writes the given value.
      Specified by:
      store in interface ProCAKEWriter
      Parameters:
      value - The object that should be stored
      Throws:
      CAKEIOException
    • insertNamespace

      public abstract void insertNamespace(GenericXMLSchemaBasedWriter writer)
      Adds the namespace-imports of this handler to the given xmlWriter.
      Parameters:
      writer - a GenericXMLSchemaBasedWriter object
    • store

      public abstract void store(Object value, GenericXMLSchemaBasedWriter writer) throws CAKEIOException
      To embed xml writers into another one it must be possible to specify the parent GenericXMLSchemaBasedWriter 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 - a Object 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 - a Object object
      writer - a GenericXMLSchemaBasedWriter object
      Throws:
      IOException
      CAKEIOException