Class OPFItems


  • public final class OPFItems
    extends java.lang.Object
    Represents the set of Publication Resources in a Package Document (OPF).
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private OPFItems​(java.lang.Iterable<OPFItem> items, java.lang.Iterable<java.lang.String> spineIDs)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static OPFItems build​(java.util.Map<java.lang.String,​OPFItem.Builder> itemBuilders, java.lang.Iterable<java.lang.String> spineIDs, ValidationContext context)
      Creates a consolidated set of OPFItem from item builders and a list of spine item IDs.
      com.google.common.base.Optional<OPFItem> getItemById​(java.lang.String id)
      Search the item with the given ID.
      com.google.common.base.Optional<OPFItem> getItemByURL​(io.mola.galimatias.URL url)
      Search the item with the given path.
      java.util.List<OPFItem> getItems()
      Returns the list of items in this set, in document order.
      java.util.List<OPFItem> getSpineItems()
      Returns the list of items in the spine.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • items

        private final java.util.List<OPFItem> items
      • spine

        private final java.util.List<OPFItem> spine
      • itemsById

        private final java.util.Map<java.lang.String,​OPFItem> itemsById
      • itemsByURL

        private final java.util.Map<io.mola.galimatias.URL,​OPFItem> itemsByURL
    • Constructor Detail

      • OPFItems

        private OPFItems​(java.lang.Iterable<OPFItem> items,
                         java.lang.Iterable<java.lang.String> spineIDs)
    • Method Detail

      • getItemById

        public com.google.common.base.Optional<OPFItem> getItemById​(java.lang.String id)
        Search the item with the given ID.
        Parameters:
        id - the ID of the item to search, can be null.
        Returns:
        An Optional containing the item if found, or Optional.absent() if not found.
      • getItemByURL

        public com.google.common.base.Optional<OPFItem> getItemByURL​(io.mola.galimatias.URL url)
        Search the item with the given path.
        Parameters:
        id - the URL of the item to search, can be null.
        Returns:
        An Optional containing the item if found, or Optional.absent() if not found.
      • getSpineItems

        public java.util.List<OPFItem> getSpineItems()
        Returns the list of items in the spine. A single OPFItem instance can appear multiple times in the list.
        Returns:
        the list of items in the spine.
      • getItems

        public java.util.List<OPFItem> getItems()
        Returns the list of items in this set, in document order.
        Returns:
        the list of items in this set.
      • build

        public static OPFItems build​(java.util.Map<java.lang.String,​OPFItem.Builder> itemBuilders,
                                     java.lang.Iterable<java.lang.String> spineIDs,
                                     ValidationContext context)
        Creates a consolidated set of OPFItem from item builders and a list of spine item IDs.
        Parameters:
        itemBuilders - the builders of the OPFItem in the set.
        spineIDs - the IDs of the items in the spine.
        context -
        Returns:
        a consolidated set of OPFItems.