-
- All Implemented Interfaces:
-
org.readium.r2.shared.publication.PublicationServicesHolder,org.readium.r2.shared.util.SuspendingCloseable
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 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.PositionListFactorypublic classPublication.OpeningException
-
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 final Manifestmanifestprivate Map<ReadiumCSSName, Boolean>userSettingsUIPresetprivate StringcssStyle
-
Constructor Summary
Constructors Constructor Description Publication(Manifest manifest, Container<Resource> container, 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.ERROR) 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 ManifestgetManifest()final Map<ReadiumCSSName, Boolean>getUserSettingsUIPreset()final UnitsetUserSettingsUIPreset(@Deprecated(message = Migrate to the new Settings API (see migration guide), level = DeprecationLevel.ERROR) Map<ReadiumCSSName, Boolean> userSettingsUIPreset)final StringgetCssStyle()final UnitsetCssStyle(@Deprecated(message = Migrate to the new Settings API (see migration guide), level = DeprecationLevel.ERROR) String cssStyle)final Urlurl(Locator locator)Returns the URL to the resource represented by the given locator, relative to the publication's link with selfrelation.final Urlurl(Link link, Map<String, String> parameters)Returns the URL to the resource represented by the given link, relative to the publication's link with selfrelation.final Urlurl(Href href, Map<String, String> parameters)Returns the URL to the resource represented by the given href, relative to the publication's link with selfrelation.final BooleanconformsTo(Publication.Profile profile)Returns whether this publication conforms to the given Readium Web Publication Profile. final LinklinkWithHref(Url 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. final Resourceget(Url href)Returns the resource targeted by the given href. 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()Copy the Publication with a different PositionListFactory. final Linkresource(String href)final URLbaseUrl()final UnitaddSelfLink(String endPoint, URL baseURL)final LinkresourceWithHref(String href)final Linklink(Function1<Link, Boolean> predicate)final JSONObjecttoJSON()final ReadingProgressioncontentLayoutForLanguage(String language)-
-
Constructor Detail
-
Publication
Publication(Manifest manifest, Container<Resource> container, Publication.ServicesBuilder servicesBuilder, Map<ReadiumCSSName, Boolean> userSettingsUIPreset, String cssStyle)
- Parameters:
manifest- The manifest holding the publication metadata extracted from the publication file.container- The underlying container 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.ERROR) 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()
-
getManifest
final Manifest getManifest()
-
getUserSettingsUIPreset
final Map<ReadiumCSSName, Boolean> getUserSettingsUIPreset()
-
setUserSettingsUIPreset
final Unit setUserSettingsUIPreset(@Deprecated(message = Migrate to the new Settings API (see migration guide), level = DeprecationLevel.ERROR) Map<ReadiumCSSName, Boolean> userSettingsUIPreset)
-
getCssStyle
final String getCssStyle()
-
setCssStyle
final Unit setCssStyle(@Deprecated(message = Migrate to the new Settings API (see migration guide), level = DeprecationLevel.ERROR) String cssStyle)
-
url
final Url url(Locator locator)
Returns the URL to the resource represented by the given locator, relative to the publication's link with
selfrelation.
-
url
final Url url(Link link, Map<String, String> parameters)
Returns the URL to the resource represented by the given link, relative to the publication's link with
selfrelation.If the link HREF is a template, the parameters are used to expand it according to RFC 6570.
-
url
final Url url(Href href, Map<String, String> parameters)
Returns the URL to the resource represented by the given href, relative to the publication's link with
selfrelation.If the HREF is a template, the parameters are used to expand it according to RFC 6570.
-
conformsTo
final Boolean conformsTo(Publication.Profile profile)
Returns whether this publication conforms to the given Readium Web Publication Profile.
-
linkWithHref
final Link linkWithHref(Url href)
Finds the first Link with the given HREF in the publication's links.
Searches through (in order) readingOrder, resources and links recursively following
alternateandchildrenlinks.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()
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)
-
toJSON
final JSONObject toJSON()
-
contentLayoutForLanguage
final ReadingProgression contentLayoutForLanguage(String language)
-
-
-
-