Package org.daisy.dotify.api.translator
Class BrailleTranslatorFactoryMaker
- java.lang.Object
-
- org.daisy.dotify.api.translator.BrailleTranslatorFactoryMaker
-
- All Implemented Interfaces:
BrailleTranslatorFactoryMakerService
public class BrailleTranslatorFactoryMaker extends Object implements BrailleTranslatorFactoryMakerService
Provides a braille translator factory maker. This class will look for implementations of the BrailleTranslatorFactory interface using the services API. It will return the first implementation that matches the requested specification.This class can be overridden by extending it and adding a reference to the new implementation to the services API. This class will then choose the new implementation when a new instance is requested.
-
-
Constructor Summary
Constructors Constructor Description BrailleTranslatorFactoryMaker()
Creates a new braille translator factory maker.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFactory(BrailleTranslatorFactoryService factory)
Adds a factory (intended for use by the OSGi framework).Collection<TranslatorSpecification>
listSpecifications()
Returns a list of supported specifications.BrailleTranslatorFactory
newFactory(String locale, String grade)
Gets a factory for the given specification.static BrailleTranslatorFactoryMaker
newInstance()
Creates a new BrailleTranslatorFactoryMaker and populates it using the SPI (java service provider interface).BrailleTranslator
newTranslator(String locale, String grade)
Gets a translator for the given specification.void
removeFactory(BrailleTranslatorFactoryService factory)
Removes a factory (intended for use by the OSGi framework).boolean
supportsSpecification(String locale, String grade)
Returns true if the translator factory supports the given specification.
-
-
-
Method Detail
-
newInstance
public static BrailleTranslatorFactoryMaker newInstance()
Creates a new BrailleTranslatorFactoryMaker and populates it using the SPI (java service provider interface).
In an OSGi context, an instance should be retrieved using the service registry. It will be registered under the BrailleTranslatorFactoryMakerService interface.
- Returns:
- returns a new braille translator factory maker.
-
addFactory
public void addFactory(BrailleTranslatorFactoryService factory)
Adds a factory (intended for use by the OSGi framework).- Parameters:
factory
- the factory to add
-
removeFactory
public void removeFactory(BrailleTranslatorFactoryService factory)
Removes a factory (intended for use by the OSGi framework).- Parameters:
factory
- the factory to remove
-
supportsSpecification
public boolean supportsSpecification(String locale, String grade)
Description copied from interface:BrailleTranslatorFactoryMakerService
Returns true if the translator factory supports the given specification.- Specified by:
supportsSpecification
in interfaceBrailleTranslatorFactoryMakerService
- Parameters:
locale
- the translator localegrade
- the translator grade, or null for uncontracted braille- Returns:
- returns true if the translator factory supports the specification
-
newFactory
public BrailleTranslatorFactory newFactory(String locale, String grade) throws TranslatorConfigurationException
Gets a factory for the given specification.- Specified by:
newFactory
in interfaceBrailleTranslatorFactoryMakerService
- Parameters:
locale
- the locale for the factorygrade
- the grade for the factory- Returns:
- returns a braille translator factory
- Throws:
TranslatorConfigurationException
- if the specification is not supported
-
newTranslator
public BrailleTranslator newTranslator(String locale, String grade) throws TranslatorConfigurationException
Description copied from interface:BrailleTranslatorFactoryMakerService
Gets a translator for the given specification.- Specified by:
newTranslator
in interfaceBrailleTranslatorFactoryMakerService
- Parameters:
locale
- the locale for the translatorgrade
- the grade for the translator- Returns:
- returns a braille translator
- Throws:
TranslatorConfigurationException
- if the specification is not supported
-
listSpecifications
public Collection<TranslatorSpecification> listSpecifications()
Description copied from interface:BrailleTranslatorFactoryMakerService
Returns a list of supported specifications.- Specified by:
listSpecifications
in interfaceBrailleTranslatorFactoryMakerService
- Returns:
- returns a list of specifications
-
-