Class OPFHandler

All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, EntityResolver2, LexicalHandler
Direct Known Subclasses:
OPFHandler30

public class OPFHandler extends XMLHandler
  • Field Details

    • TEXT

      protected static final String TEXT
      See Also:
    • pageMapId

      protected String pageMapId
    • pageMapReferenceLocation

      protected EPUBLocation pageMapReferenceLocation
    • itemBuilders

      protected final Map<String, OPFItem.Builder> itemBuilders
    • itemBuildersByURL

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

      private final List<String> spineIDs
    • items

      private OPFItems items
    • refs

      private final Vector<OPFReference> refs
    • validRoles

      private static final HashSet<String> validRoles
    • uniqueIdent

      private String uniqueIdent
    • uniqueIdentExists

      private boolean uniqueIdentExists
    • uid

      String uid
    • opf12PackageFile

      private boolean opf12PackageFile
    • spineItemCounter

      private int spineItemCounter
  • Constructor Details

  • Method Details

    • getPath

      public String getPath()
    • getOpf12PackageFile

      public boolean getOpf12PackageFile()
    • getOpf20PackageFile

      public boolean getOpf20PackageFile()
    • getItemById

      public com.google.common.base.Optional<OPFItem> getItemById(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 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 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 String getUid()
    • isValidRole

      private static boolean isValidRole(String role)
    • startElement

      public void startElement()
      Overrides:
      startElement in class XMLHandler
    • getIdentId

      public String getIdentId()
    • endElement

      public void endElement()
      Overrides:
      endElement in class XMLHandler
    • characters

      public void characters(char[] chars, int start, int len)
      Specified by:
      characters in interface ContentHandler
      Overrides:
      characters in class 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.