Class Resources
java.lang.Object
nl.siegmann.epublib.domain.Resources
- All Implemented Interfaces:
Serializable
All the resources that make up the book.
XHTML files, images and epub xml documents must be here.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a resource to the resources.voidaddAll(Collection<Resource> resources) Adds all resources from the given Collection of resources to the existing collection.booleancontainsByHref(String href) Whether there exists a resource with the given hrefbooleancontainsId(String id) Whether the map of resources already contains a resource with the given id.private StringcreateHref(MediaType mediaType, int counter) private StringcreateUniqueResourceId(Resource resource) Creates a new resource id that is guaranteed to be unique for this set of Resourcesstatic ResourcefindFirstResourceByMediaType(Collection<Resource> resources, MediaType mediaType) Gets the first resource (random order) with the give mediatype.findFirstResourceByMediaType(MediaType mediaType) Gets the first resource (random order) with the give mediatype.private voidfixResourceHref(Resource resource) voidfixResourceId(Resource resource) Checks the id of the given resource and changes to a unique identifier if it isn't one already.getAll()All resource hrefsGets the resource with the given href.Gets the resource with the given id.getByIdOrHref(String idOrHref) First tries to find a resource with as id the given idOrHref, if that fails it tries to find one with the idOrHref as href.private StringgetResourceItemPrefix(Resource resource) The resources that make up this book.getResourcesByMediaType(MediaType mediaType) All resources that have the given MediaType.getResourcesByMediaTypes(MediaType[] mediaTypes) All Resources that match any of the given list of MediaTypesbooleanisEmpty()private StringmakeValidId(String resourceId, Resource resource) Check if the id is a valid identifier.Remove the resource with the given href.voidset(Collection<Resource> resources) Sets the collection of Resources to the given collection of resourcesvoidSets the collection of Resources to the given collection of resourcesintsize()The number of resources
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
IMAGE_PREFIX
- See Also:
-
ITEM_PREFIX
- See Also:
-
lastId
private int lastId -
resources
-
-
Constructor Details
-
Resources
public Resources()
-
-
Method Details
-
add
-
fixResourceId
Checks the id of the given resource and changes to a unique identifier if it isn't one already.- Parameters:
resource-
-
makeValidId
-
getResourceItemPrefix
-
createUniqueResourceId
-
containsId
Whether the map of resources already contains a resource with the given id.- Parameters:
id-- Returns:
- Whether the map of resources already contains a resource with the given id.
-
getById
-
remove
-
fixResourceHref
-
createHref
-
isEmpty
public boolean isEmpty() -
size
public int size()The number of resources- Returns:
- The number of resources
-
getResourceMap
-
getAll
-
containsByHref
Whether there exists a resource with the given href- Parameters:
href-- Returns:
- Whether there exists a resource with the given href
-
set
Sets the collection of Resources to the given collection of resources- Parameters:
resources-
-
addAll
Adds all resources from the given Collection of resources to the existing collection.- Parameters:
resources-
-
set
-
getByIdOrHref
-
getByHref
-
findFirstResourceByMediaType
Gets the first resource (random order) with the give mediatype. Useful for looking up the table of contents as it's supposed to be the only resource with NCX mediatype.- Parameters:
mediaType-- Returns:
- the first resource (random order) with the give mediatype.
-
findFirstResourceByMediaType
public static Resource findFirstResourceByMediaType(Collection<Resource> resources, MediaType mediaType) Gets the first resource (random order) with the give mediatype. Useful for looking up the table of contents as it's supposed to be the only resource with NCX mediatype.- Parameters:
mediaType-- Returns:
- the first resource (random order) with the give mediatype.
-
getResourcesByMediaType
-
getResourcesByMediaTypes
-
getAllHrefs
-