Class OutputFactory

  extended byde.dante.util.framework.AbstractFactory
      extended byde.dante.extex.backend.outputStream.OutputFactory
All Implemented Interfaces:
Configurable, LogEnabled, OutputStreamFactory, RegistrarObserver

public class OutputFactory
extends AbstractFactory
implements OutputStreamFactory

This factory creates an output stream from a specification in the configuration.

$Revision: 1.5 $
Gerd Neugebauer

Constructor Summary
OutputFactory(java.lang.String[] outdirs, java.lang.String basename)
          Creates a new object.
Method Summary getOutputStream(java.lang.String name, java.lang.String type)
          Create an output stream of a certain type.
protected openOutputStream(java.lang.String dir, java.lang.String filename, boolean isDefault)
          This method tries to open a new output stream.
 void register(OutputStreamObserver observer)
          Register an observer which is invoked to notify about any output stream requested via a call to getOututStream(),
 void register(java.lang.String type, OutputFactory factory)
          Register a handler for creation of an output stream of a certain type.
 void setDefaultStream( defaultStream)
          Setter for defaultStream.
 void setExtension(java.lang.String extension)
          Setter for the default extension.
Methods inherited from class de.dante.util.framework.AbstractFactory
configure, configure, createInstance, createInstance, createInstance, createInstanceForConfiguration, createInstanceForConfiguration, createInstanceForConfiguration, enableLogging, enableLogging, getConfiguration, getLogger, reconnect, selectConfiguration
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public OutputFactory(java.lang.String[] outdirs,
                     java.lang.String basename)
              throws ConfigurationException
Creates a new object.

outdirs - the list of output directories
basename - the base name of the main stream
ConfigurationException - in case of an configuration error
Method Detail


public getOutputStream(java.lang.String name,
                                            java.lang.String type)
                                     throws DocumentWriterException
Create an output stream of a certain type. The creation is tried in a number of directories. The first succeeding attempt is returned.

Specified by:
getOutputStream in interface OutputStreamFactory
name - the name of the file to open
type - the type of the file
a stream for the output or null if none could be opened.
DocumentWriterException - in case of an error
See Also:
OutputStreamFactory.getOutputStream( java.lang.String, java.lang.String)


protected openOutputStream(java.lang.String dir,
                                                java.lang.String filename,
                                                boolean isDefault)
This method tries to open a new output stream.

dir - the directory or null
filename - the file name
isDefault - the indicator whether the file should be saved
the output stream or null


public void register(OutputStreamObserver observer)
Description copied from interface: OutputStreamFactory
Register an observer which is invoked to notify about any output stream requested via a call to getOututStream(),

Specified by:
register in interface OutputStreamFactory
observer - the observers to register
See Also:
OutputStreamFactory.register( de.dante.extex.backend.outputStream.OutputStreamObserver)


public void register(java.lang.String type,
                     OutputFactory factory)
Register a handler for creation of an output stream of a certain type. If no handler is registered then an appropriate file is opened.

You can register a handler if you want to redirect certain output streams to different directions. For instance if you want to process an output stream in memory. For instance this can be the case if an integrated preview can be used instead of writing the output to a file.

type - the type
factory - the handler to be invoked


public void setDefaultStream( defaultStream)
Setter for defaultStream.

defaultStream - the defaultStream to set


public void setExtension(java.lang.String extension)
Description copied from interface: OutputStreamFactory
Setter for the default extension. The default extension is used when the type specified is null.

Specified by:
setExtension in interface OutputStreamFactory
extension - the default extension
See Also:
OutputStreamFactory.setExtension( java.lang.String)