net.sf.rej.files
Class SingleFile

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

public class SingleFile
extends FileSet

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.rej.files.FileSet
serialVersionUID
 
Constructor Summary
SingleFile(java.io.File f)
           
 
Method Summary
 void addFile(java.lang.String filename)
          Add a file to the set.
 void close()
          Call close for all FileInputStream objects returned by calls to getInputStream(String filename)
static SingleFile 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)
          Remove file denoted by filename from the set.
 void save(Modifications ms)
           
 void saveAs(java.io.File file, Modifications ms)
           
 void write(byte[] data)
           
 void write(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

SingleFile

public SingleFile(java.io.File f)
           throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException
Method Detail

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

getInputStream

public java.io.InputStream getInputStream(java.lang.String file)
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.

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.

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

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.

write

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

write

public void write(java.io.InputStream is)
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
Call close for all FileInputStream objects returned by calls to getInputStream(String filename)

Specified by:
close in class FileSet

removeFile

public void removeFile(java.lang.String filename)
Description copied from class: FileSet
Remove file denoted by filename from the set. The file is not actually removed, but could be just marked for removal in the next serialization.

Specified by:
removeFile in class FileSet
Parameters:
filename - String file to remove

addFile

public void addFile(java.lang.String filename)
Description copied from class: FileSet
Add a file to the set. File will be identified by filename.

Specified by:
addFile in class FileSet
Parameters:
filename - String file to add

refresh

public void refresh()
Description copied from class: FileSet
Refresh the FileSet, loading the contents from the filesystem

Specified by:
refresh in class FileSet

save

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

saveAs

public void saveAs(java.io.File file,
                   Modifications ms)
            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

removeAllFiles

public void removeAllFiles()
Specified by:
removeAllFiles in class FileSet

createNew

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

getClasspath

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