Class ResourceRegistry


  • public final class ResourceRegistry
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<io.mola.galimatias.URL,​java.util.List<java.lang.String>> ids  
      private com.google.common.collect.Table<io.mola.galimatias.URL,​java.lang.String,​Reference.Type> idTypes  
      private java.util.Map<io.mola.galimatias.URL,​Resource> resources  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getIDPosition​(java.lang.String id, Resource resource)
      Returns the position of the given ID in the document represented by this resource.
      Reference.Type getIDType​(java.lang.String id, Resource resource)  
      java.lang.String getMimeType​(io.mola.galimatias.URL resource)  
      java.util.Optional<OPFItem> getOPFItem​(io.mola.galimatias.URL url)
      Returns an Optional containing the Package Document item for the given Publication Resource path, or Optional#absent() if no resource has been registered for the given path.
      java.util.Optional<Resource> getResource​(io.mola.galimatias.URL url)
      Returns an Optional containing the Package Document item for the given Publication Resource path, or Optional#absent() if no resource has been registered for the given path.
      void registerID​(java.lang.String id, Reference.Type type, io.mola.galimatias.URL resourceURL)  
      void registerResource​(OPFItem item)  
      void registerResource​(io.mola.galimatias.URL url, java.lang.String mimetype)  
      • Methods inherited from class java.lang.Object

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

      • resources

        private java.util.Map<io.mola.galimatias.URL,​Resource> resources
      • ids

        private java.util.Map<io.mola.galimatias.URL,​java.util.List<java.lang.String>> ids
      • idTypes

        private com.google.common.collect.Table<io.mola.galimatias.URL,​java.lang.String,​Reference.Type> idTypes
    • Constructor Detail

      • ResourceRegistry

        public ResourceRegistry()
    • Method Detail

      • registerID

        public void registerID​(java.lang.String id,
                               Reference.Type type,
                               io.mola.galimatias.URL resourceURL)
      • getIDPosition

        public int getIDPosition​(java.lang.String id,
                                 Resource resource)
        Returns the position of the given ID in the document represented by this resource.
        Parameters:
        resource -
        Returns:
        -1 if the ID wasn't found in the document, or 0 if the given ID is null or an empty string, or the 1-based position of the ID otherwise.
      • registerResource

        public void registerResource​(OPFItem item)
      • registerResource

        public void registerResource​(io.mola.galimatias.URL url,
                                     java.lang.String mimetype)
      • getMimeType

        public java.lang.String getMimeType​(io.mola.galimatias.URL resource)
      • getOPFItem

        public java.util.Optional<OPFItem> getOPFItem​(io.mola.galimatias.URL url)
        Returns an Optional containing the Package Document item for the given Publication Resource path, or Optional#absent() if no resource has been registered for the given path.
      • getResource

        public java.util.Optional<Resource> getResource​(io.mola.galimatias.URL url)
        Returns an Optional containing the Package Document item for the given Publication Resource path, or Optional#absent() if no resource has been registered for the given path.