sam.entry
Class Entry

java.lang.Object
  |
  +--sam.entry.Entry

public class Entry
extends java.lang.Object

This class is a basic abstraction over files for the purpose of archiving.

Instances of this class are fully immutable. Note also that this class has no public constructor as it should only be instantiated through an Enumerator sub-class.

See Also:
Enumerator, FileSystem

Field Summary
 long date
          Actual last access time of this entry.
static sam.entry.Entry DUMMY
          Dummy entry for testing/debugging purposes
 long length
          Actual total number of bytes contained by this entry.
 java.lang.String name
          Actual name of this entry.
 
Method Summary
 java.io.OutputStream compare(sam.event.FileEventNotifier notifier, java.io.File actualDirectory)
          Gets an OutputStream ready for comparing this entry to the file stored into specific directory.
 java.io.OutputStream freshen(sam.event.FileEventNotifier notifier, java.io.File actualDirectory)
          Gets an OutputStream ready for freshening this entry into specific directory.
 java.io.InputStream getInputStream()
          Returns an InputStream for reading this entry, assumed it is a local file.
 boolean isOlderThanIn(java.io.File outputDirectory)
          Wether this entry denotes a file which is older than an already existing file ins specified directory.
 java.lang.String list(sam.rules.ModusOperandi modusOperandi)
          Lists this entry in Unix-like format.
protected static java.lang.String mangleFileName(java.lang.String fileName, java.io.File basePath)
          Mangles a native file name to an Entry path.
 java.io.OutputStream overwrite(sam.event.FileEventNotifier notifier, java.io.File actualDirectory)
          Gets an OutputStream ready for writing this entry into specific directory.
 java.io.InputStream read(sam.event.FileEventNotifier notifier)
          Gets an InputStream ready for reading the file corresponding the this entry.
 java.io.OutputStream skip(sam.event.FileEventNotifier notifier, java.io.File actualDirectory)
          Gets an OutputStream ready for skipping this entry.
 java.io.File toFile()
          Unmangles this Entry path to native file name.
 java.io.File toFile(java.io.File basePath)
          Unmangles this Entry path to native file name.
 java.lang.String toString()
          Returns a human-readable description of this entry
 java.lang.String verbose()
          Makes a verbose description of this entry including its name and size.
 java.io.OutputStream write(sam.event.FileEventNotifier notifier, java.io.File actualDirectory)
          Gets an OutputStream ready for writing this entry into specific directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DUMMY

public static final sam.entry.Entry DUMMY
Dummy entry for testing/debugging purposes


length

public final long length
Actual total number of bytes contained by this entry.


name

public final java.lang.String name
Actual name of this entry. The patch separator is specified in ArchiveLayout.ENTRY_PATH_SEPARATOR Warning: native Files should not be created with this field as a parameter but through the toFile method instead.


date

public final long date
Actual last access time of this entry.

Method Detail

list

public java.lang.String list(sam.rules.ModusOperandi modusOperandi)
Lists this entry in Unix-like format.


toString

public java.lang.String toString()
Returns a human-readable description of this entry

Overrides:
toString in class java.lang.Object

verbose

public java.lang.String verbose()
Makes a verbose description of this entry including its name and size.

"./foo" (25kb)


getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an InputStream for reading this entry, assumed it is a local file.

java.io.IOException

isOlderThanIn

public boolean isOlderThanIn(java.io.File outputDirectory)
Wether this entry denotes a file which is older than an already existing file ins specified directory.

Parameters:
outputDirectory - the output directory to place the file in.
Returns:
wether target file already exists an is newer than this entry.

mangleFileName

protected static java.lang.String mangleFileName(java.lang.String fileName,
                                                 java.io.File basePath)
Mangles a native file name to an Entry path.

Parameters:
basePath - the base path, or null
See Also:
ArchiveLayout.ENTRY_PATH_SEPARATOR

toFile

public java.io.File toFile()
Unmangles this Entry path to native file name.

See Also:
ArchiveLayout.ENTRY_PATH_SEPARATOR

toFile

public java.io.File toFile(java.io.File basePath)
Unmangles this Entry path to native file name.

Parameters:
basePath - the base path, or null
See Also:
ArchiveLayout.ENTRY_PATH_SEPARATOR

read

public java.io.InputStream read(sam.event.FileEventNotifier notifier)
Gets an InputStream ready for reading the file corresponding the this entry. This entry is supposed to either have an absolute path or to designate a path relative to the current working directory.

Parameters:
notifier - the FileEvent notifier to report events through

write

public java.io.OutputStream write(sam.event.FileEventNotifier notifier,
                                  java.io.File actualDirectory)
Gets an OutputStream ready for writing this entry into specific directory. If the target file already exists, this will ask the user wether it should be overwritten.

Parameters:
notifier - the FileEvent notifier to report events through
actualDirectory - the base directory to extract the file into (relative path is preserved).

freshen

public java.io.OutputStream freshen(sam.event.FileEventNotifier notifier,
                                    java.io.File actualDirectory)
Gets an OutputStream ready for freshening this entry into specific directory. If the target file already exists and is older then it will be overwritten.

Parameters:
notifier - the FileEvent notifier to report events through
actualDirectory - the base directory to extract the file into (relative path is preserved).

skip

public java.io.OutputStream skip(sam.event.FileEventNotifier notifier,
                                 java.io.File actualDirectory)
Gets an OutputStream ready for skipping this entry.

Parameters:
notifier - the FileEvent notifier to report events through
actualDirectory - the base directory to extract the file into (relative path is preserved).

overwrite

public java.io.OutputStream overwrite(sam.event.FileEventNotifier notifier,
                                      java.io.File actualDirectory)
Gets an OutputStream ready for writing this entry into specific directory. The target file is overwritten if it already exists.

Parameters:
notifier - the FileEvent notifier to report events through
actualDirectory - the base directory to extract the file into (relative path is preserved).

compare

public java.io.OutputStream compare(sam.event.FileEventNotifier notifier,
                                    java.io.File actualDirectory)
Gets an OutputStream ready for comparing this entry to the file stored into specific directory.

Parameters:
notifier - the FileEvent notifier to report events through
actualDirectory - the base directory where the file to compared against is stored (relative path is preserved).