Class ResourcesLoader


  • public class ResourcesLoader
    extends java.lang.Object
    Loads Resources from inputStreams, ZipFiles, etc
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger LOG  
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourcesLoader()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static ZipEntry getNextZipEntry​(ZipInputStream zipInputStream)  
      static Resources loadResources​(ZipFile zipFile, java.lang.String defaultHtmlEncoding)
      Loads all entries from the ZipInputStream as Resources.
      static Resources loadResources​(ZipFile zipFile, java.lang.String defaultHtmlEncoding, java.util.List<MediaType> lazyLoadedTypes)
      Loads the entries of the zipFile as resources.
      static Resources loadResources​(ZipInputStream zipInputStream, java.lang.String defaultHtmlEncoding)
      Loads all entries from the ZipInputStream as Resources.
      private static boolean shouldLoadLazy​(java.lang.String href, java.util.Collection<MediaType> lazilyLoadedMediaTypes)
      Whether the given href will load a mediaType that is in the collection of lazilyLoadedMediaTypes.
      • Methods inherited from class java.lang.Object

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

      • LOG

        private static final org.slf4j.Logger LOG
    • Constructor Detail

      • ResourcesLoader

        public ResourcesLoader()
    • Method Detail

      • loadResources

        public static Resources loadResources​(ZipFile zipFile,
                                              java.lang.String defaultHtmlEncoding,
                                              java.util.List<MediaType> lazyLoadedTypes)
                                       throws java.io.IOException
        Loads the entries of the zipFile as resources. The MediaTypes that are in the lazyLoadedTypes will not get their contents loaded, but are stored as references to entries into the ZipFile and are loaded on demand by the Resource system.
        Parameters:
        zipFile -
        defaultHtmlEncoding -
        lazyLoadedTypes -
        Returns:
        Throws:
        java.io.IOException
      • shouldLoadLazy

        private static boolean shouldLoadLazy​(java.lang.String href,
                                              java.util.Collection<MediaType> lazilyLoadedMediaTypes)
        Whether the given href will load a mediaType that is in the collection of lazilyLoadedMediaTypes.
        Parameters:
        href -
        lazilyLoadedMediaTypes -
        Returns:
        Whether the given href will load a mediaType that is in the collection of lazilyLoadedMediaTypes.
      • loadResources

        public static Resources loadResources​(ZipInputStream zipInputStream,
                                              java.lang.String defaultHtmlEncoding)
                                       throws java.io.IOException
        Loads all entries from the ZipInputStream as Resources. Loads the contents of all ZipEntries into memory. Is fast, but may lead to memory problems when reading large books on devices with small amounts of memory.
        Parameters:
        zipInputStream -
        defaultHtmlEncoding -
        Returns:
        Throws:
        java.io.IOException
      • getNextZipEntry

        private static ZipEntry getNextZipEntry​(ZipInputStream zipInputStream)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • loadResources

        public static Resources loadResources​(ZipFile zipFile,
                                              java.lang.String defaultHtmlEncoding)
                                       throws java.io.IOException
        Loads all entries from the ZipInputStream as Resources. Loads the contents of all ZipEntries into memory. Is fast, but may lead to memory problems when reading large books on devices with small amounts of memory.
        Parameters:
        zipFile -
        defaultHtmlEncoding -
        Returns:
        Throws:
        java.io.IOException