Class ZipXmlThemeResourceProvider

java.lang.Object
org.oscim.theme.ZipXmlThemeResourceProvider
All Implemented Interfaces:
XmlThemeResourceProvider

public class ZipXmlThemeResourceProvider extends Object implements XmlThemeResourceProvider
Resource provider reading resource files out of a zip input stream.

Resources are cached.

  • Constructor Details

    • ZipXmlThemeResourceProvider

      public ZipXmlThemeResourceProvider(ZipInputStream zipInputStream) throws IOException
      Parameters:
      zipInputStream - zip stream to read resources from
      Throws:
      IOException - if a problem occurs reading the stream
    • ZipXmlThemeResourceProvider

      public ZipXmlThemeResourceProvider(ZipInputStream zipInputStream, int maxResourceSizeToCache) throws IOException
      Parameters:
      zipInputStream - zip stream to read resources from
      maxResourceSizeToCache - only resources in the zip stream with a maximum size of this parameter (in bytes) are cached and provided
      Throws:
      IOException - if a problem occurs reading the stream
  • Method Details

    • createInputStream

      public InputStream createInputStream(String relativePath, String source)
      Specified by:
      createInputStream in interface XmlThemeResourceProvider
      Parameters:
      relativePath - a relative path to use as a base for search in the resource provuider
      source - a source string parsed out of an XML render theme "src" attribute.
      Returns:
      an InputStream to read the resource data from.
    • getCount

      public int getCount()
      Returns:
      the number of files in the archive.
    • getXmlThemes

      public List<String> getXmlThemes()
      Returns:
      the XML theme paths in the archive.
    • scanXmlThemes

      public static List<String> scanXmlThemes(ZipInputStream zipInputStream) throws IOException
      Scans a given zip stream for contained xml themes without actually reading and storing its content in memory.

      This method is useful to find out which xml themes are available across multiple zip files without actually have to read them all into memory.

      Parameters:
      zipInputStream - zip stream to read resources from
      Returns:
      the XML theme paths in the archive
      Throws:
      IOException - if a problem occurs reading the stream