org.extex.backend.documentWriter
Class DocumentWriterFactory

java.lang.Object
  extended by AbstractFactory
      extended by org.extex.backend.documentWriter.DocumentWriterFactory

public class DocumentWriterFactory
extends AbstractFactory

This is the factory to provide an instance of a document writer.

The class to be instantiated can implements one or more interfaces which trigger special actions:

Configurable
If this interface is implemented then a Configuration is passed in with the interface method.
LogEnabled
If this interface is implemented then a Logger is passed in with the interface method.
SingleDocumentStream
If this interface is implemented then a OutputStream is passed in with the interface method.
MultipleDocumentStream
If this interface is implemented then a OutputStreamFactory is passed in with the interface method.

Version:
$Revision:5563 $
Author:
Gerd Neugebauer

Constructor Summary
DocumentWriterFactory(Configuration configuration, java.util.logging.Logger logger)
          Creates a new object.
 
Method Summary
 boolean check(java.lang.String type)
          Check that a given document writer type has a matching configuration.
 DocumentWriter newInstance(java.lang.String type, OutputStreamFactory outFactory)
          Provide a new instance of a document writer.
 void setOptions(DocumentWriterOptions options)
          Setter for options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentWriterFactory

public DocumentWriterFactory(Configuration configuration,
                             java.util.logging.Logger logger)
                      throws ConfigurationException
Creates a new object.

Parameters:
configuration - the configuration to use for the factory
logger - the logger
Throws:
ConfigurationException - in case of an error
Method Detail

newInstance

public DocumentWriter newInstance(java.lang.String type,
                                  OutputStreamFactory outFactory)
                           throws DocumentWriterException
Provide a new instance of a document writer. The new instance is initiated with the sub-configuration describing it.

If the generated instance implements the interface SingleDocumentStream then the method setOutputStream of this interface is invoked.

If the generated instance implements the interface MultipleDocumentStream then the method setOutputStreamFactory of this interface is invoked.

Parameters:
type - the type of the document writer
outFactory - the factory for further output streams
Returns:
the new instance
Throws:
DocumentWriterException - in case of a problem
ConfigurationException - in case of a configuration problem

check

public boolean check(java.lang.String type)
              throws ConfigurationException
Check that a given document writer type has a matching configuration.

Parameters:
type - the document writer type
Returns:
true iff a configuration exists
Throws:
ConfigurationException - in case of an error; especially if the configuration is not found

setOptions

public void setOptions(DocumentWriterOptions options)
Setter for options.

Parameters:
options - the dynamic access to the readable part of the context