net.sf.rej.files
Class Folder

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

public class Folder
extends FileSet

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.rej.files.FileSet
serialVersionUID
 
Constructor Summary
Folder(java.io.File f)
           
 
Method Summary
 void addFile(java.lang.String filename)
          Add a file to the set.
static void addTraversal(java.lang.String base, java.io.File file, java.util.List<java.lang.String> al)
           
 void close()
          Close the FileSet.
static Folder createNew(java.io.File file)
           
 void finishSerialization()
           
 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.
 java.io.File getTarget(java.lang.String file)
           
 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 mods)
           
 void saveAs(java.io.File file, Modifications mods)
           
 void startSerialization()
           
 void write(java.io.File file, byte[] data)
           
 void write(java.io.File file, java.io.InputStream is)
           
 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

Folder

public Folder(java.io.File f)
       throws java.io.IOException
Throws:
java.io.IOException
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

getTarget

public java.io.File getTarget(java.lang.String 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.

addTraversal

public static void addTraversal(java.lang.String base,
                                java.io.File file,
                                java.util.List<java.lang.String> al)

startSerialization

public void startSerialization()

write

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

write

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

finishSerialization

public void finishSerialization()

write

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

write

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

close

public void close()
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

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 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

removeAllFiles

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

createNew

public static Folder 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