Package org.mapsforge.map.rendertheme
Class ZipXmlThemeResourceProvider
- java.lang.Object
-
- org.mapsforge.map.rendertheme.ZipXmlThemeResourceProvider
-
- All Implemented Interfaces:
XmlThemeResourceProvider
public class ZipXmlThemeResourceProvider extends java.lang.Object implements XmlThemeResourceProvider
Resource provider reading resource files out of a zip input stream.Resources are cached.
-
-
Constructor Summary
Constructors Constructor Description ZipXmlThemeResourceProvider(java.util.zip.ZipInputStream zipInputStream)
ZipXmlThemeResourceProvider(java.util.zip.ZipInputStream zipInputStream, int maxResourceSizeToCache)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStream
createInputStream(java.lang.String relativePath, java.lang.String source)
int
getCount()
java.util.List<java.lang.String>
getXmlThemes()
static java.util.List<java.lang.String>
scanXmlThemes(java.util.zip.ZipInputStream zipInputStream)
Scans a given zip stream for contained xml themes without actually reading and storing its content in memory.
-
-
-
Constructor Detail
-
ZipXmlThemeResourceProvider
public ZipXmlThemeResourceProvider(java.util.zip.ZipInputStream zipInputStream) throws java.io.IOException
- Parameters:
zipInputStream
- zip stream to read resources from- Throws:
java.io.IOException
- if a problem occurs reading the stream
-
ZipXmlThemeResourceProvider
public ZipXmlThemeResourceProvider(java.util.zip.ZipInputStream zipInputStream, int maxResourceSizeToCache) throws java.io.IOException
- Parameters:
zipInputStream
- zip stream to read resources frommaxResourceSizeToCache
- only resources in the zip stream with a maximum size of this parameter (in bytes) are cached and provided- Throws:
java.io.IOException
- if a problem occurs reading the stream
-
-
Method Detail
-
createInputStream
public java.io.InputStream createInputStream(java.lang.String relativePath, java.lang.String source)
- Specified by:
createInputStream
in interfaceXmlThemeResourceProvider
- Parameters:
relativePath
- a relative path to use as a base for search in the resource provuidersource
- 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 java.util.List<java.lang.String> getXmlThemes()
- Returns:
- the XML theme paths in the archive.
-
scanXmlThemes
public static java.util.List<java.lang.String> scanXmlThemes(java.util.zip.ZipInputStream zipInputStream) throws java.io.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:
java.io.IOException
- if a problem occurs reading the stream
-
-