-
- All Implemented Interfaces:
-
org.readium.r2.shared.publication.PublicationServicesHolder
public final class Publication implements PublicationServicesHolder
The Publication shared model is the entry-point for all the metadata and services related to a Readium publication.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumPublication.TYPEpublic enumPublication.EXTENSIONpublic classPublication.Companionpublic final classPublication.ProfileRepresents a Readium Web Publication Profile a Publication can conform to.
For a list of supported profiles, see the registry: https://readium.org/webpub-manifest/profiles/
public interfacePublication.ServiceBase interface to be implemented by all publication services.
public final classPublication.ServicesBuilderBuilds a list of Publication.Service from a collection of service factories.
Provides helpers to manipulate the list of services of a Publication.
public classPublication.OpeningExceptionErrors occurring while opening a Publication.
public final classPublication.BuilderBuilds a Publication from its components.
A Publication's construction is distributed over the Streamer and its parsers, so a builder is useful to pass the parts around.
public interfacePublication.PositionListFactoryCreates a Publication's positions.
The parsers provide an implementation of this interface for each format, but a host app might want to use a custom factory to implement, for example, a caching mechanism or use a different calculation method.
-
Field Summary
Fields Modifier and Type Field Description private final List<String>contextprivate final Metadatametadataprivate final List<Link>linksprivate final List<Link>readingOrderprivate final List<Link>resourcesprivate final List<Link>tableOfContentsprivate final Map<String, List<PublicationCollection>>subcollectionsprivate Publication.TYPEtypeprivate Doubleversionprivate final StringjsonManifestprivate final URLbaseUrlprivate final LinkcoverLinkprivate final List<Link>listOfAudioFilesprivate final List<Link>listOfVideosprivate final Map<String, List<PublicationCollection>>otherCollectionsprivate final ReadingProgressioncontentLayoutprivate Map<ReadiumCSSName, Boolean>userSettingsUIPresetprivate StringcssStyle
-
Constructor Summary
Constructors Constructor Description Publication(Manifest manifest, Fetcher fetcher, Publication.ServicesBuilder servicesBuilder, Map<ReadiumCSSName, Boolean> userSettingsUIPreset, String cssStyle)
-
Method Summary
Modifier and Type Method Description final List<String>getContext()final MetadatagetMetadata()final List<Link>getLinks()final List<Link>getReadingOrder()final List<Link>getResources()final List<Link>getTableOfContents()final Map<String, List<PublicationCollection>>getSubcollections()final Publication.TYPEgetType()final UnitsetType(@Deprecated(message = "Use conformsTo() to check the kind of a publication.", level = DeprecationLevel.WARNING) Publication.TYPE type)final DoublegetVersion()final UnitsetVersion(@Deprecated(message = "Version is not available any more.", level = DeprecationLevel.ERROR) Double version)final StringgetJsonManifest()final URLgetBaseUrl()final LinkgetCoverLink()final List<Link>getListOfAudioFiles()final List<Link>getListOfVideos()final Map<String, List<PublicationCollection>>getOtherCollections()final ReadingProgressiongetContentLayout()final Map<ReadiumCSSName, Boolean>getUserSettingsUIPreset()final UnitsetUserSettingsUIPreset(@Deprecated(message = "Migrate to the new Settings API (see migration guide)") Map<ReadiumCSSName, Boolean> userSettingsUIPreset)final StringgetCssStyle()final UnitsetCssStyle(@Deprecated(message = "Migrate to the new Settings API (see migration guide)") String cssStyle)final BooleanconformsTo(Publication.Profile profile)Returns whether this publication conforms to the given Readium Web Publication Profile. final LinklinkWithHref(String href)Finds the first Link with the given HREF in the publication's links. final LinklinkWithRel(String rel)Finds the first Link having the given rel in the publications's links. final List<Link>linksWithRel(String rel)Finds all Links having the given rel in the publications's links. final LocatorlocatorFromLink(Link link)Creates a new Locator object from a Link to a resource of this publication. final Resourceget(Link link)Returns the resource targeted by the given non-templated link. Unitclose()Closes any opened resource associated with the Publication, including services. <T extends Publication.Service> TfindService(KClass<T> serviceType)Returns the first publication service that is an instance of serviceType. <T extends Publication.Service> List<T>findServices(KClass<T> serviceType)Returns all the publication services that are instances of serviceType. final UnitsetSelfLink(String href)Sets the URL where this Publication's RWPM manifest is served. final PublicationcopyWithPositionsFactory(Function1<Publication, Publication.PositionListFactory> createFactory)Copy the Publication with a different PositionListFactory. final Linkresource(String href)final URLbaseUrl()final UnitaddSelfLink(String endPoint, URL baseURL)final LinkresourceWithHref(String href)Finds the first resource Link (asset or readingOrder item) at the given relative path. final Linklink(Function1<Link, Boolean> predicate)Finds the first Link matching the given predicate in the publications's Link properties: resources, readingOrder and links. final JSONObjecttoJSON()final ReadingProgressioncontentLayoutForLanguage(String language)-
-
Constructor Detail
-
Publication
Publication(Manifest manifest, Fetcher fetcher, Publication.ServicesBuilder servicesBuilder, Map<ReadiumCSSName, Boolean> userSettingsUIPreset, String cssStyle)
- Parameters:
manifest- The manifest holding the publication metadata extracted from the publication file.fetcher- The underlying fetcher used to read publication resources.servicesBuilder- Holds the list of service factories used to create the instances of Publication.Service attached to this Publication.
-
-
Method Detail
-
getContext
final List<String> getContext()
-
getMetadata
final Metadata getMetadata()
-
getReadingOrder
final List<Link> getReadingOrder()
-
getResources
final List<Link> getResources()
-
getTableOfContents
final List<Link> getTableOfContents()
-
getSubcollections
final Map<String, List<PublicationCollection>> getSubcollections()
-
getType
final Publication.TYPE getType()
-
setType
final Unit setType(@Deprecated(message = "Use conformsTo() to check the kind of a publication.", level = DeprecationLevel.WARNING) Publication.TYPE type)
-
getVersion
final Double getVersion()
-
setVersion
final Unit setVersion(@Deprecated(message = "Version is not available any more.", level = DeprecationLevel.ERROR) Double version)
-
getJsonManifest
final String getJsonManifest()
-
getBaseUrl
final URL getBaseUrl()
-
getCoverLink
final Link getCoverLink()
-
getListOfAudioFiles
final List<Link> getListOfAudioFiles()
-
getListOfVideos
final List<Link> getListOfVideos()
-
getOtherCollections
final Map<String, List<PublicationCollection>> getOtherCollections()
-
getContentLayout
final ReadingProgression getContentLayout()
-
getUserSettingsUIPreset
final Map<ReadiumCSSName, Boolean> getUserSettingsUIPreset()
-
setUserSettingsUIPreset
final Unit setUserSettingsUIPreset(@Deprecated(message = "Migrate to the new Settings API (see migration guide)") Map<ReadiumCSSName, Boolean> userSettingsUIPreset)
-
getCssStyle
final String getCssStyle()
-
setCssStyle
final Unit setCssStyle(@Deprecated(message = "Migrate to the new Settings API (see migration guide)") String cssStyle)
-
conformsTo
final Boolean conformsTo(Publication.Profile profile)
Returns whether this publication conforms to the given Readium Web Publication Profile.
-
linkWithHref
final Link linkWithHref(String href)
Finds the first Link with the given HREF in the publication's links.
Searches through (in order) readingOrder, resources and links recursively following alternate and children links.
If there's no match, tries again after removing any query parameter and anchor from the given href.
-
linkWithRel
final Link linkWithRel(String rel)
-
linksWithRel
final List<Link> linksWithRel(String rel)
-
locatorFromLink
final Locator locatorFromLink(Link link)
-
close
Unit close()
Closes any opened resource associated with the Publication, including services.
-
findService
<T extends Publication.Service> T findService(KClass<T> serviceType)
Returns the first publication service that is an instance of serviceType.
-
findServices
<T extends Publication.Service> List<T> findServices(KClass<T> serviceType)
Returns all the publication services that are instances of serviceType.
-
setSelfLink
final Unit setSelfLink(String href)
Sets the URL where this Publication's RWPM manifest is served.
-
copyWithPositionsFactory
final Publication copyWithPositionsFactory(Function1<Publication, Publication.PositionListFactory> createFactory)
Copy the Publication with a different PositionListFactory. The provided closure will be used to build the PositionListFactory, with this being the Publication.
-
addSelfLink
final Unit addSelfLink(String endPoint, URL baseURL)
-
resourceWithHref
final Link resourceWithHref(String href)
Finds the first resource Link (asset or readingOrder item) at the given relative path.
-
link
final Link link(Function1<Link, Boolean> predicate)
Finds the first Link matching the given predicate in the publications's Link properties: resources, readingOrder and links.
Searches through (in order) readingOrder, resources and links recursively following alternate and children links. The search order is unspecified.
-
toJSON
final JSONObject toJSON()
-
contentLayoutForLanguage
final ReadingProgression contentLayoutForLanguage(String language)
-
-
-
-