VASSAL.tools
Class DataArchive

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--VASSAL.tools.DataArchive
Direct Known Subclasses:
ArchiveWriter

public class DataArchive
extends java.lang.ClassLoader

Wrapper around a Zip archive with methods to cache images


Field Summary
protected  java.util.zip.ZipFile archive
           
protected  java.util.Vector extensions
           
static java.lang.String IMAGE_DIR
           
protected  java.lang.String[] imageNames
           
 
Constructor Summary
protected DataArchive()
           
  DataArchive(java.lang.String zipName)
           
 
Method Summary
 void addExtension(DataArchive ext)
          DataArchives can extend other archives.
protected  java.lang.Class findClass(java.lang.String name)
           
static java.awt.Image findImage(java.io.File zip, java.lang.String file)
           
static java.awt.Image findImage(java.io.File dir, java.lang.String zip, java.lang.String file)
           
 java.util.zip.ZipFile getArchive()
           
static byte[] getBytes(java.io.InputStream in)
          Read all available bytes from the given InputStream
 java.awt.Image getCachedImage(java.lang.String file)
           
static java.io.InputStream getFileStream(java.io.File zip, java.lang.String file)
           
static java.io.InputStream getFileStream(java.io.File dir, java.lang.String zipName, java.lang.String file)
           
 java.io.InputStream getFileStream(java.lang.String file)
          Get an inputstream from the given filename in the archive
static java.awt.Image getImage(java.io.InputStream in)
           
 java.lang.String[] getImageNames()
           
 java.lang.String getName()
           
 java.net.URL getURL(java.lang.String fileName)
           
 ArchiveWriter getWriter()
          Return the writeable instance of DataArchive, either this or one of its extensions (At most one archive should be being edited at a time)
protected  boolean isNameCacheStale()
           
protected  void listImageNames(java.util.Vector v)
          Place the names of the image files stored in this DataArchive into the argument Vector
 java.lang.Class loadClass(java.lang.String name, boolean resolve)
           
 void unCacheImage(java.lang.String file)
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

archive

protected java.util.zip.ZipFile archive

extensions

protected java.util.Vector extensions

imageNames

protected java.lang.String[] imageNames

IMAGE_DIR

public static final java.lang.String IMAGE_DIR
See Also:
Constant Field Values
Constructor Detail

DataArchive

protected DataArchive()

DataArchive

public DataArchive(java.lang.String zipName)
            throws java.io.IOException
Method Detail

getName

public java.lang.String getName()

getArchive

public java.util.zip.ZipFile getArchive()

findImage

public static java.awt.Image findImage(java.io.File zip,
                                       java.lang.String file)
                                throws java.io.IOException
java.io.IOException

getFileStream

public static java.io.InputStream getFileStream(java.io.File zip,
                                                java.lang.String file)
                                         throws java.io.IOException
java.io.IOException

findImage

public static java.awt.Image findImage(java.io.File dir,
                                       java.lang.String zip,
                                       java.lang.String file)
                                throws java.io.IOException
java.io.IOException

getCachedImage

public java.awt.Image getCachedImage(java.lang.String file)
                              throws java.io.IOException
java.io.IOException

unCacheImage

public void unCacheImage(java.lang.String file)

getImage

public static java.awt.Image getImage(java.io.InputStream in)
                               throws java.io.IOException
java.io.IOException

getBytes

public static byte[] getBytes(java.io.InputStream in)
                       throws java.io.IOException
Read all available bytes from the given InputStream

java.io.IOException

getFileStream

public java.io.InputStream getFileStream(java.lang.String file)
                                  throws java.io.IOException
Get an inputstream from the given filename in the archive

java.io.IOException

getURL

public java.net.URL getURL(java.lang.String fileName)
                    throws java.io.IOException
java.io.IOException

addExtension

public void addExtension(DataArchive ext)
DataArchives can extend other archives. The extensions will be searched for data if not found in the parent archive

Parameters:
ext - the extension

getWriter

public ArchiveWriter getWriter()
Return the writeable instance of DataArchive, either this or one of its extensions (At most one archive should be being edited at a time)

Returns:

getFileStream

public static java.io.InputStream getFileStream(java.io.File dir,
                                                java.lang.String zipName,
                                                java.lang.String file)

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 boolean resolve)
                          throws java.lang.ClassNotFoundException
Overrides:
loadClass in class java.lang.ClassLoader
java.lang.ClassNotFoundException

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Overrides:
findClass in class java.lang.ClassLoader
java.lang.ClassNotFoundException

getImageNames

public java.lang.String[] getImageNames()

isNameCacheStale

protected boolean isNameCacheStale()

listImageNames

protected void listImageNames(java.util.Vector v)
Place the names of the image files stored in this DataArchive into the argument Vector

Parameters:
v -