net.sf.rej.files
Class Archive

java.lang.Object
  extended by net.sf.rej.files.FileSet
      extended by net.sf.rej.files.Archive
All Implemented Interfaces:
java.io.Serializable

public class Archive
extends FileSet

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.rej.files.FileSet
serialVersionUID
 
Constructor Summary
Archive(java.io.File f)
           
 
Method Summary
 void addFile(java.lang.String filename)
          Mark file as to be added to archive.
 void close()
          Close the FileSet.
static Archive createNew(java.io.File file)
           
 java.lang.String getClasspath(java.lang.String mainClass)
           
 java.util.List<java.lang.String> getContentsList()
          Get the contents of this file set, ie. the list of files that are included in this set.
 byte[] getData(java.lang.String file)
          Get the contents of file belonging in this set, identified by file.
 java.io.InputStream getInputStream(java.lang.String file)
          Get an InputStream to contents of a file in this set, identified by file.
 long getLength(java.lang.String file)
          Get the length of the file in this set identified by file.
 java.lang.String getName()
          Return the name of the set.
 void partialSave(java.lang.String filename, byte[] data)
           
 void refresh()
          Refresh the FileSet, loading the contents from the filesystem
 void removeAllFiles()
           
 void removeFile(java.lang.String filename)
          Mark file as to-be-removed.
 void save(Modifications mods)
           
 void saveAs(java.io.File file, Modifications mods)
           
 void write(java.lang.String filename, byte[] data)
           
 void write(java.lang.String filename, java.io.InputStream is)
           
 
Methods inherited from class net.sf.rej.files.FileSet
equals, getChecksum, getContentsFrom, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Archive

public Archive(java.io.File f)
        throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getContentsList

public java.util.List<java.lang.String> getContentsList()
Description copied from class: FileSet
Get the contents of this file set, ie. the list of files that are included in this set.

Specified by:
getContentsList in class FileSet
Returns:
List object contaning Strings representing filenames.

getData

public byte[] getData(java.lang.String file)
               throws java.io.IOException
Description copied from class: FileSet
Get the contents of file belonging in this set, identified by file.

Specified by:
getData in class FileSet
Parameters:
file - String the file to get
Returns:
byte array with the contents of the file
Throws:
java.io.IOException - Some of the internal I/O caused an exception

getName

public java.lang.String getName()
Description copied from class: FileSet
Return the name of the set. Being the filename of the archive, folder or single file, etc.

Specified by:
getName in class FileSet
Returns:
Name of the set.

getInputStream

public java.io.InputStream getInputStream(java.lang.String file)
                                   throws java.io.IOException
Description copied from class: FileSet
Get an InputStream to contents of a file in this set, identified by file. Should be preferred ahead of getData(String) particularly with big files.

Specified by:
getInputStream in class FileSet
Parameters:
file - String the file to get
Returns:
InputStream to the contents of the file.
Throws:
java.io.IOException - Some of the internal I/O caused an exception

getLength

public long getLength(java.lang.String file)
Description copied from class: FileSet
Get the length of the file in this set identified by file.

Specified by:
getLength in class FileSet
Parameters:
file - String name of the file whose size is requested.
Returns:
long Size of the file

write

public void write(java.lang.String filename,
                  byte[] data)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.lang.String filename,
                  java.io.InputStream is)
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from class: FileSet
Close the FileSet. Free up resources. The contents of the FileSet cannot be accessed again after calling close().

Specified by:
close in class FileSet
Throws:
java.io.IOException - I/O problem closing the FileSet

addFile

public void addFile(java.lang.String filename)
Mark file as to be added to archive.

Specified by:
addFile in class FileSet
Parameters:
filename - String

removeFile

public void removeFile(java.lang.String filename)
Mark file as to-be-removed. On next save it will not be saved.

Specified by:
removeFile in class FileSet
Parameters:
filename - String

refresh

public void refresh()
             throws java.io.IOException
Description copied from class: FileSet
Refresh the FileSet, loading the contents from the filesystem

Specified by:
refresh in class FileSet
Throws:
java.io.IOException - I/O problem during refresh

save

public void save(Modifications mods)
          throws java.io.IOException
Specified by:
save in class FileSet
Throws:
java.io.IOException

saveAs

public void saveAs(java.io.File file,
                   Modifications mods)
            throws java.io.IOException
Specified by:
saveAs in class FileSet
Throws:
java.io.IOException

partialSave

public void partialSave(java.lang.String filename,
                        byte[] data)
                 throws java.io.IOException
Throws:
java.io.IOException

createNew

public static Archive createNew(java.io.File file)
                         throws java.io.IOException
Throws:
java.io.IOException

removeAllFiles

public void removeAllFiles()
                    throws java.io.IOException
Specified by:
removeAllFiles in class FileSet
Throws:
java.io.IOException

getClasspath

public java.lang.String getClasspath(java.lang.String mainClass)
Specified by:
getClasspath in class FileSet