de.dante.extex.language.impl
Class LoadingLanguageManager

java.lang.Object
  extended byde.dante.util.framework.AbstractFactory
      extended byde.dante.extex.language.impl.BaseLanguageManager
          extended byde.dante.extex.language.impl.LoadingLanguageManager
All Implemented Interfaces:
Configurable, LanguageCreator, LanguageManager, LogEnabled, OutputStreamConsumer, RegistrarObserver, ResourceConsumer, java.io.Serializable

public class LoadingLanguageManager
extends BaseLanguageManager
implements LanguageCreator, ResourceConsumer, OutputStreamConsumer

This class manages the Languages. It is a container which can be asked to provide an appropriate instance. This instance is either taken from existing instances or a new instance is created. Since at the time of creation it can not be decided whether a new one should be used or an existing one should be loaded a future object is returned which enables us to postpone the operation until the decision can be made.

The future object invokes one of the methods of LanguageCreator. In this case we know whether to create or load the language. Thus the appropriate operation is performed and the resulting language is put into the map overwriting the future object.

TODO gene: documentation incomplete

Configuration

This instance is configurable. The configuration is used to select the appropriate class and optional parameters for a requested instance. In this respect this class makes best use of the infrastructure of the AbstractFactory.

Version:
$Revision: 1.13 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
LoadingLanguageManager()
          Creates a new object.
 
Method Summary
protected  Language createLanguage(java.lang.String name)
          Create a new language and put it into the table.
 Language createLanguageInstance(java.lang.String name)
          Create a new instance for the given index if required.
 Language loadLanguageInstance(java.lang.String name)
          Load or create a new instance for the given index if required.
protected  java.lang.Object readResolve()
          Restore the internal state when the instance is loaded from file.
protected  boolean saveTable(java.lang.String name, Language value)
          Try to save the hyphenation table by other means.
 void setOutputStreamFactory(OutputStreamFactory factory)
          This method takes an output stream factory for further use.
 void setResourceFinder(ResourceFinder finder)
          Setter for the resource finder.
 
Methods inherited from class de.dante.extex.language.impl.BaseLanguageManager
getLanguage, getLocalizer, getTables
 
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
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail

LoadingLanguageManager

public LoadingLanguageManager()
Creates a new object.

Method Detail

createLanguage

protected Language createLanguage(java.lang.String name)
Description copied from class: BaseLanguageManager
Create a new language and put it into the table.

Overrides:
createLanguage in class BaseLanguageManager
Parameters:
name - the name of the language
Returns:
the new instance of a language
See Also:
BaseLanguageManager.createLanguage( java.lang.String)

createLanguageInstance

public Language createLanguageInstance(java.lang.String name)
                                throws HyphenationException
Description copied from interface: LanguageCreator
Create a new instance for the given index if required.

Specified by:
createLanguageInstance in interface LanguageCreator
Parameters:
name - the symbolic name of the language
Returns:
the new instance
Throws:
HyphenationException - in case of an error
See Also:
LanguageCreator.createLanguageInstance( java.lang.String)

loadLanguageInstance

public Language loadLanguageInstance(java.lang.String name)
                              throws HyphenationException
Description copied from interface: LanguageCreator
Load or create a new instance for the given index if required.

Specified by:
loadLanguageInstance in interface LanguageCreator
Parameters:
name - the symbolic name of the language
Returns:
the new instance
Throws:
HyphenationException - in case of an error
See Also:
LanguageCreator.loadLanguageInstance( java.lang.String)

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Restore the internal state when the instance is loaded from file.

Overrides:
readResolve in class BaseLanguageManager
Returns:
the object which should be used instead of the one read
Throws:
java.io.ObjectStreamException - in case of an error

saveTable

protected boolean saveTable(java.lang.String name,
                            Language value)
                     throws java.io.IOException,
                            DocumentWriterException
Try to save the hyphenation table by other means. This can be used to write the result to another place than the default output stream.

The table is not saved if the name is purely numeric. This guarantees the backward compatibility with TeX, since TeX uses numerical names for hyphenation tables only.

Parameters:
name - the name of the table
value - the table itself
Returns:
true iff the table has been saved
Throws:
java.io.IOException - in case of an IO error
DocumentWriterException - in case of an error

setOutputStreamFactory

public void setOutputStreamFactory(OutputStreamFactory factory)
Description copied from interface: OutputStreamConsumer
This method takes an output stream factory for further use.

Specified by:
setOutputStreamFactory in interface OutputStreamConsumer
Parameters:
factory - the output stream factory to use
See Also:
OutputStreamConsumer.setOutputStreamFactory( de.dante.extex.backend.outputStream.OutputStreamFactory)

setResourceFinder

public void setResourceFinder(ResourceFinder finder)
Description copied from interface: ResourceConsumer
Setter for the resource finder.

Specified by:
setResourceFinder in interface ResourceConsumer
Parameters:
finder - the resource finder
See Also:
ResourceConsumer.setResourceFinder( de.dante.util.resource.ResourceFinder)