de.dante.extex.backend.outputStream
Class OutputFactory

java.lang.Object
  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.

Version:
$Revision: 1.5 $
Author:
Gerd Neugebauer

Constructor Summary
OutputFactory(java.lang.String[] outdirs, java.lang.String basename)
          Creates a new object.
 
Method Summary
 java.io.OutputStream getOutputStream(java.lang.String name, java.lang.String type)
          Create an output stream of a certain type.
protected  java.io.OutputStream 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(java.io.OutputStream 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

OutputFactory

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

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

getOutputStream

public java.io.OutputStream 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
Parameters:
name - the name of the file to open
type - the type of the file
Returns:
a stream for the output or null if none could be opened.
Throws:
DocumentWriterException - in case of an error
See Also:
OutputStreamFactory.getOutputStream( java.lang.String, java.lang.String)

openOutputStream

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

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

register

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
Parameters:
observer - the observers to register
See Also:
OutputStreamFactory.register( de.dante.extex.backend.outputStream.OutputStreamObserver)

register

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.

Parameters:
type - the type
factory - the handler to be invoked

setDefaultStream

public void setDefaultStream(java.io.OutputStream defaultStream)
Setter for defaultStream.

Parameters:
defaultStream - the defaultStream to set

setExtension

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
Parameters:
extension - the default extension
See Also:
OutputStreamFactory.setExtension( java.lang.String)