Class OPFHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.EntityResolver2, org.xml.sax.ext.LexicalHandler
    Direct Known Subclasses:
    OPFHandler30

    public class OPFHandler
    extends XMLHandler
    • Field Detail

      • pageMapId

        protected java.lang.String pageMapId
      • pageMapReferenceLocation

        protected EPUBLocation pageMapReferenceLocation
      • itemBuilders

        protected final java.util.Map<java.lang.String,​OPFItem.Builder> itemBuilders
      • itemBuildersByURL

        protected final java.util.Map<io.mola.galimatias.URL,​OPFItem.Builder> itemBuildersByURL
      • spineIDs

        private final java.util.List<java.lang.String> spineIDs
      • validRoles

        private static final java.util.HashSet<java.lang.String> validRoles
      • uniqueIdent

        private java.lang.String uniqueIdent
      • uniqueIdentExists

        private boolean uniqueIdentExists
      • uid

        java.lang.String uid
      • opf12PackageFile

        private boolean opf12PackageFile
      • spineItemCounter

        private int spineItemCounter
    • Method Detail

      • getPath

        public java.lang.String getPath()
      • getOpf12PackageFile

        public boolean getOpf12PackageFile()
      • getOpf20PackageFile

        public boolean getOpf20PackageFile()
      • getItemById

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

        public com.google.common.base.Optional<OPFItem> getItemByURL​(io.mola.galimatias.URL url)
        Search the list of item by URL.
        Parameters:
        id - the URL of the item to search
        Returns:
        an Optional containing the item of the given URL if found, or Optional.absent()
      • getSpineItems

        public java.util.List<OPFItem> getSpineItems()
        Returns an immutable list of the items in the spine. May contain duplicates if several itemref elements point to the same item.

        Returns the empty list if the items have not been parsed yet.

        Returns:
        the list of items in the spine, guaranteed non-null.
      • getItems

        public java.util.List<OPFItem> getItems()
        Returns an immutable list of all the items in the OPF, in document order, including those represented by link elements pointing to local resources.

        Returns the empty list if the items have not been parsed yet.

        Returns:
        the list of all items, guaranteed non-null.
      • getReferenceCount

        public int getReferenceCount()
      • getReference

        public OPFReference getReference​(int index)
      • checkUniqueIdentExists

        public boolean checkUniqueIdentExists()
        Checks to see if the unique-identifier attribute of the package element references an existing DC metadata identifier element's id attribute
        Returns:
        true if there is an identifier with an id attribute that matches the value of the unique-identifier attribute of the package element. False otherwise.
      • getUid

        public java.lang.String getUid()
      • isValidRole

        private static boolean isValidRole​(java.lang.String role)
      • getIdentId

        public java.lang.String getIdentId()
      • characters

        public void characters​(char[] chars,
                               int start,
                               int len)
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
      • buildItems

        private void buildItems()
      • reportItem

        protected void reportItem​(OPFItem item)
        Report features or messages for a given item.
        Parameters:
        item - the item to report.