Class ZipMap
- java.lang.Object
-
- com.inductiveautomation.ignition.common.util.ZipMap
-
- All Implemented Interfaces:
java.util.Map<java.lang.String,ZipMapFile>
public class ZipMap extends java.lang.Object implements java.util.Map<java.lang.String,ZipMapFile>
The ZipMap provides a convenient way of working with zip files by providing aMap
that is backed by a zip file.A variety of constructors are available for creating the ZipMap. Once loaded, you can work with file objects as you would work with any normal map. To save changes, you must call writeToFile.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ZipMap.ZipMapFileImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
protected void
ensureAllLoaded()
java.util.Set<java.util.Map.Entry<java.lang.String,ZipMapFile>>
entrySet()
ZipMapFile
get(java.lang.Object key)
boolean
isEmpty()
java.util.Set<java.lang.String>
keySet()
protected byte[]
loadEntry(java.util.zip.ZipEntry e)
ZipMapFile
put(java.lang.String key, byte[] value)
Convenience method for putting a file into the ZipMap.ZipMapFile
put(java.lang.String key, ZipMapFile value)
Puts an entry into the ZipMap.ZipMapFile
put(java.lang.String key, java.io.File value)
Convenience method for putting a file into the ZipMap.void
putAll(java.util.Map<? extends java.lang.String,? extends ZipMapFile> t)
ZipMapFile
remove(java.lang.Object key)
int
size()
java.util.Collection<ZipMapFile>
values()
void
writeToFile(java.io.File outputFile)
Write the contents of this ZipMap to a zip file using the supplied File.void
writeToFile(java.io.OutputStream outputStream)
Write the contents of this ZipMap to a zip file using the supplied OutputStream.
-
-
-
Constructor Detail
-
ZipMap
public ZipMap()
Creates an empty ZipMap. Changes need to be explicitly written usingwriteToFile(File)
orwriteToFile(OutputStream)
.
-
ZipMap
public ZipMap(java.io.File zipFile) throws java.io.IOException
Create a ZipMap with the contents of the given zip file. Changes need to be explicitly written usingwriteToFile(File)
orwriteToFile(OutputStream)
.- Throws:
java.io.IOException
-
ZipMap
public ZipMap(java.io.InputStream zipFile) throws java.io.IOException
Create a ZipMap with the contents of the given zip file. Changes need to be explicitly written usingwriteToFile(File)
orwriteToFile(OutputStream)
.- Throws:
java.io.IOException
-
-
Method Detail
-
loadEntry
protected byte[] loadEntry(java.util.zip.ZipEntry e)
-
ensureAllLoaded
protected void ensureAllLoaded() throws java.io.IOException
- Throws:
java.io.IOException
-
writeToFile
public void writeToFile(java.io.File outputFile) throws java.io.IOException
Write the contents of this ZipMap to a zip file using the supplied File.- Parameters:
outputFile
- the file to write to- Throws:
java.io.IOException
- on failure to write
-
writeToFile
public void writeToFile(java.io.OutputStream outputStream) throws java.io.IOException
Write the contents of this ZipMap to a zip file using the supplied OutputStream.- Throws:
java.io.IOException
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
entrySet
@Nonnull public java.util.Set<java.util.Map.Entry<java.lang.String,ZipMapFile>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
get
public ZipMapFile get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
keySet
@Nonnull public java.util.Set<java.lang.String> keySet()
- Specified by:
keySet
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
put
public ZipMapFile put(java.lang.String key, ZipMapFile value)
Puts an entry into the ZipMap. Directory names should end with a "/".- Specified by:
put
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
put
public ZipMapFile put(java.lang.String key, java.io.File value)
Convenience method for putting a file into the ZipMap.- Parameters:
key
- Name of the file. Example: "hello.txt" or "dir/world.txt".value
- The file itself. A ZipMapFile will be created from this File.- Returns:
- The ZipMapFile added to the ZipMap.
-
put
public ZipMapFile put(java.lang.String key, byte[] value)
Convenience method for putting a file into the ZipMap.- Parameters:
key
- Name of the file. Example: "hello.txt" or "dir/world.txt".value
- The byte[] itself. A ZipMapFile will be created from this byte[] with directory=false.- Returns:
- The ZipMapFile added to the ZipMap.
-
putAll
public void putAll(java.util.Map<? extends java.lang.String,? extends ZipMapFile> t)
- Specified by:
putAll
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
remove
public ZipMapFile remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
values
@Nonnull public java.util.Collection<ZipMapFile> values()
- Specified by:
values
in interfacejava.util.Map<java.lang.String,ZipMapFile>
-
-