net.sf.rej.files
Class FileSet

java.lang.Object
  extended by net.sf.rej.files.FileSet
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Archive, Folder, SingleFile

public abstract class FileSet
extends java.lang.Object
implements java.io.Serializable

FileSet objects model sets of files, such as a single file, a folder (and subfolders) or an archive file. For implementing classes, note that the path elements of the files contained within a fileset must be delimited by a forward slahs '/' in order for some of the other funcionalities, such as refactoring to work.

Author:
Sami Koivu
See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Constructor Summary
FileSet()
           
 
Method Summary
abstract  void addFile(java.lang.String filename)
          Add a file to the set.
abstract  void close()
          Close the FileSet.
 boolean equals(java.lang.Object other)
           
 long getChecksum()
          A checksum of the fileset used to invalidate cached class indices for fast searching.
abstract  java.lang.String getClasspath(java.lang.String mainClass)
           
 void getContentsFrom(FileSet fs)
           
abstract  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.
abstract  byte[] getData(java.lang.String file)
          Get the contents of file belonging in this set, identified by file.
abstract  java.io.InputStream getInputStream(java.lang.String file)
          Get an InputStream to contents of a file in this set, identified by file.
abstract  long getLength(java.lang.String file)
          Get the length of the file in this set identified by file.
abstract  java.lang.String getName()
          Return the name of the set.
 int hashCode()
           
abstract  void refresh()
          Refresh the FileSet, loading the contents from the filesystem
abstract  void removeAllFiles()
           
abstract  void removeFile(java.lang.String filename)
          Remove file denoted by filename from the set.
abstract  void save(Modifications ms)
           
abstract  void saveAs(java.io.File file, Modifications ms)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

FileSet

public FileSet()
Method Detail

getContentsList

public abstract 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.

Returns:
List object contaning Strings representing filenames.

getData

public abstract byte[] getData(java.lang.String file)
                        throws java.io.IOException
Get the contents of file belonging in this set, identified by file.

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 abstract java.lang.String getName()
Return the name of the set. Being the filename of the archive, folder or single file, etc.

Returns:
Name of the set.

getInputStream

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

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 abstract long getLength(java.lang.String file)
                        throws java.io.IOException
Get the length of the file in this set identified by file.

Parameters:
file - String name of the file whose size is requested.
Returns:
long Size of the file
Throws:
java.io.IOException - Underlying I/O caused an exception

close

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

Throws:
java.io.IOException - I/O problem closing the FileSet

removeFile

public abstract void removeFile(java.lang.String filename)
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.

Parameters:
filename - String file to remove

addFile

public abstract void addFile(java.lang.String filename)
Add a file to the set. File will be identified by filename.

Parameters:
filename - String file to add

refresh

public abstract void refresh()
                      throws java.io.IOException
Refresh the FileSet, loading the contents from the filesystem

Throws:
java.io.IOException - I/O problem during refresh

getChecksum

public long getChecksum()
                 throws java.io.IOException
A checksum of the fileset used to invalidate cached class indices for fast searching.

Returns:
A checksum value.
Throws:
java.io.IOException - A problem in the I/O processing.

save

public abstract void save(Modifications ms)
                   throws java.io.IOException
Throws:
java.io.IOException

saveAs

public abstract void saveAs(java.io.File file,
                            Modifications ms)
                     throws java.io.IOException
Throws:
java.io.IOException

removeAllFiles

public abstract void removeAllFiles()
                             throws java.io.IOException
Throws:
java.io.IOException

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

getContentsFrom

public void getContentsFrom(FileSet fs)
                     throws java.io.IOException
Throws:
java.io.IOException

getClasspath

public abstract java.lang.String getClasspath(java.lang.String mainClass)