VASSAL.tools
Class ArchiveWriter

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--VASSAL.tools.DataArchive
                    |
                    +--VASSAL.tools.ArchiveWriter

public class ArchiveWriter
extends DataArchive

An ArchiveWriter is a writeable DataArchive. New files may be added with the addFile(java.lang.String, java.lang.String) and addImage(java.lang.String, java.lang.String) methods.


Fields inherited from class VASSAL.tools.DataArchive
archive, extensions, IMAGE_DIR, imageNames
 
Constructor Summary
ArchiveWriter(java.lang.String zipName)
          Create a new writeable archive.
ArchiveWriter(java.util.zip.ZipFile archive)
           
 
Method Summary
 void addFile(java.lang.String name, java.io.InputStream stream)
          Copy an InputStream into the archive
 void addFile(java.lang.String path, java.lang.String name)
          Copy a file from the user's filesystem to the archive.
 void addImage(java.lang.String path, java.lang.String name)
          Add an image file to the archive.
 java.io.InputStream getFileStream(java.lang.String name)
          Overrides DataArchive.getFileStream(java.io.File, java.lang.String) to return streams that have been added to the archive but not yet written to disk.
protected  void listImageNames(java.util.Vector v)
          Place the names of the image files stored in this DataArchive into the argument Vector
 void saveAs()
           
 void write()
          If the ArchiveWriter was initialized with non-null file name, then write the contents of the archive to the named archive.
 
Methods inherited from class VASSAL.tools.DataArchive
addExtension, createScaledInstance, findClass, findImage, findImage, getArchive, getBytes, getCachedImage, getFileStream, getFileStream, getImage, getImageBounds, getImageNames, getName, getPermissions, getScaledImage, getScaledImage, getURL, getWriter, improvedScaling, isNameCacheStale, loadClass, unCacheImage, unCacheImage
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArchiveWriter

public ArchiveWriter(java.lang.String zipName)
Create a new writeable archive.
Parameters:
zipName - the name of the archive. If null, the user will be prompted for a filename when saving. If not null, new entries will be added to the named archive. If the file exists and is not a zip archive, it will be overwritten.

ArchiveWriter

public ArchiveWriter(java.util.zip.ZipFile archive)
Method Detail

addImage

public void addImage(java.lang.String path,
                     java.lang.String name)
Add an image file to the archive. The file will be copied into an "images" directory in the archive. Storing another image with the same name will overwrite the previous image.
Parameters:
path - the full path of the image file on the user's filesystem
name - the name under which to store the image in the archive

addFile

public void addFile(java.lang.String path,
                    java.lang.String name)
Copy a file from the user's filesystem to the archive.
Parameters:
path - the full path of the file on the user's filesystem
name - the name under which to store the file in the archive

addFile

public void addFile(java.lang.String name,
                    java.io.InputStream stream)
Copy an InputStream into the archive
Parameters:
name - the name under which to store the contents of the stream
stream - the stream to copy

getFileStream

public java.io.InputStream getFileStream(java.lang.String name)
                                  throws java.io.IOException
Overrides DataArchive.getFileStream(java.io.File, java.lang.String) to return streams that have been added to the archive but not yet written to disk.
Overrides:
getFileStream in class DataArchive

saveAs

public void saveAs()
            throws java.io.IOException

write

public void write()
           throws java.io.IOException
If the ArchiveWriter was initialized with non-null file name, then write the contents of the archive to the named archive. If it was initialized with a null name, prompt the user to select a new file into which to write archive

listImageNames

protected void listImageNames(java.util.Vector v)
Description copied from class: DataArchive
Place the names of the image files stored in this DataArchive into the argument Vector
Overrides:
listImageNames in class DataArchive
Following copied from class: VASSAL.tools.DataArchive
Parameters:
v -