Package org.daisy.dotify.api.paper
Class PaperCatalog
- java.lang.Object
-
- org.daisy.dotify.api.paper.PaperCatalog
-
- All Implemented Interfaces:
PaperCatalogService
public class PaperCatalog extends Object implements PaperCatalogService
Provides a catalog of Paper factories.
-
-
Constructor Summary
Constructors Constructor Description PaperCatalog()
Creates a new empty instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFactory(PaperProvider factory)
Adds a factory (intended for use by the OSGi framework)boolean
addNewRollPaper(String name, String desc, Length across)
Adds a new roll paper to the collection.boolean
addNewSheetPaper(String name, String desc, Length width, Length height)
Adds a new sheet paper to the collection.boolean
addNewTractorPaper(String name, String desc, Length across, Length along)
Adds a new tractor paper to the collection.Paper
get(String identifier)
Gets a paper by identifier.boolean
isRemovable(Paper paper)
Returns true if the paper can be removed, false otherwiseCollection<Paper>
list()
Lists all available papers.Collection<Paper>
list(PaperFilter filter)
Lists available papers that the filter accepts.static PaperCatalog
newInstance()
Creates a new PaperCatalog and populates it using the SPI (java service provider interface).boolean
remove(Paper p)
Removes the specified paper from the collection.void
removeFactory(PaperProvider factory)
Removes a factory (intended for use by the OSGi framework)boolean
supportsUserPapers()
Returns true if user papers are supported, false otherwise.
-
-
-
Method Detail
-
newInstance
public static PaperCatalog newInstance()
Creates a new PaperCatalog 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 PaperCatalogService interface.
- Returns:
- returns a new PaperCatalogCatalog
-
addFactory
public void addFactory(PaperProvider factory)
Adds a factory (intended for use by the OSGi framework)- Parameters:
factory
- the factory to add
-
removeFactory
public void removeFactory(PaperProvider factory)
Removes a factory (intended for use by the OSGi framework)- Parameters:
factory
- the factory to remove
-
get
public Paper get(String identifier)
Description copied from interface:PaperCatalogService
Gets a paper by identifier.- Specified by:
get
in interfacePaperCatalogService
- Parameters:
identifier
- the identifier of the paper- Returns:
- returns the paper
-
list
public Collection<Paper> list()
Description copied from interface:PaperCatalogService
Lists all available papers.- Specified by:
list
in interfacePaperCatalogService
- Returns:
- returns a list of papers
-
list
public Collection<Paper> list(PaperFilter filter)
Description copied from interface:PaperCatalogService
Lists available papers that the filter accepts.- Specified by:
list
in interfacePaperCatalogService
- Parameters:
filter
- the filter- Returns:
- returns a list of papers
-
supportsUserPapers
public boolean supportsUserPapers()
Description copied from interface:PaperCatalogService
Returns true if user papers are supported, false otherwise. If this method returns false,PaperCatalogService.addNewSheetPaper(String, String, Length, Length)
,PaperCatalogService.addNewRollPaper(String, String, Length)
,PaperCatalogService.addNewTractorPaper(String, String, Length, Length)
,PaperCatalogService.isRemovable(Paper)
,PaperCatalogService.remove(Paper)
should not be used.- Specified by:
supportsUserPapers
in interfacePaperCatalogService
- Returns:
- true if user papers are supported, false otherwise
-
addNewSheetPaper
public boolean addNewSheetPaper(String name, String desc, Length width, Length height)
Description copied from interface:PaperCatalogService
Adds a new sheet paper to the collection.- Specified by:
addNewSheetPaper
in interfacePaperCatalogService
- Parameters:
name
- the namedesc
- the descriptionwidth
- the widthheight
- the height- Returns:
- true if the paper was added successfully, false otherwise
-
addNewTractorPaper
public boolean addNewTractorPaper(String name, String desc, Length across, Length along)
Description copied from interface:PaperCatalogService
Adds a new tractor paper to the collection.- Specified by:
addNewTractorPaper
in interfacePaperCatalogService
- Parameters:
name
- the namedesc
- the descriptionacross
- the length across the feedalong
- the length along the feed- Returns:
- true if the paper was added successfully, false otherwise
-
addNewRollPaper
public boolean addNewRollPaper(String name, String desc, Length across)
Description copied from interface:PaperCatalogService
Adds a new roll paper to the collection.- Specified by:
addNewRollPaper
in interfacePaperCatalogService
- Parameters:
name
- the namedesc
- the descriptionacross
- the length across the feed- Returns:
- true if the paper was added successfully, false otherwise
-
isRemovable
public boolean isRemovable(Paper paper)
Description copied from interface:PaperCatalogService
Returns true if the paper can be removed, false otherwise- Specified by:
isRemovable
in interfacePaperCatalogService
- Parameters:
paper
- the paper- Returns:
- true if the paper can be removed, false otherwise
-
remove
public boolean remove(Paper p)
Description copied from interface:PaperCatalogService
Removes the specified paper from the collection.- Specified by:
remove
in interfacePaperCatalogService
- Parameters:
p
- the paper to remove- Returns:
- true if the paper was successfully removed, false otherwise
-
-