net.sf.xbus.technical.file
Class FileBase

java.lang.Object
  extended by net.sf.xbus.technical.file.FileBase
Direct Known Subclasses:
FileReceiver, FileSender, SimpleFileSender

public abstract class FileBase
extends java.lang.Object

Class FileBase is the abstract base class for the FileReceiverand FileSenderclasses.

It provides the methods for the copying, renaming and deleting physical files.


Constructor Summary
FileBase()
           
 
Method Summary
protected  void copyFile(java.lang.String sourceFile, java.lang.String targetFile)
          Copies data by opening FileInput/OutputStreams from the one file to another denoted by these abstract pathnames
protected  void deleteFile(java.lang.String srcFilename)
          Deletes the file or directory denoted by this abstract pathname.
static java.lang.String getEncoding(java.lang.String system)
          Reads the file encoding for the given system name from the Configuration.
protected  long getFileLength(java.lang.String filename)
           
protected  int getLastByteOfFile(java.lang.String filename)
           
protected  void renameFile(java.lang.String srcFilename, java.lang.String destFilename)
          Renames one file to another denoted by these abstract pathnames.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileBase

public FileBase()
Method Detail

getEncoding

public static java.lang.String getEncoding(java.lang.String system)
                                    throws XException
Reads the file encoding for the given system name from the Configuration. If this one is non-existent, returns default value from the system property.

Parameters:
system - name which encoding must be read
Returns:
file encoding from the standart configuration or default value from the system property
Throws:
XException - if any error occurs.

renameFile

protected void renameFile(java.lang.String srcFilename,
                          java.lang.String destFilename)
                   throws XException
Renames one file to another denoted by these abstract pathnames.

Parameters:
srcFilename - abstract pathname for the file to be renamed
destFilename - abstract pathname for the named file
Throws:
XException - if any error occurs

copyFile

protected void copyFile(java.lang.String sourceFile,
                        java.lang.String targetFile)
                 throws XException
Copies data by opening FileInput/OutputStreams from the one file to another denoted by these abstract pathnames

Parameters:
sourceFile - abstract pathname of the source file
targetFile - abstract pathname of the target file
Throws:
XException - if any error occurs

deleteFile

protected void deleteFile(java.lang.String srcFilename)
                   throws XException
Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.

Parameters:
srcFilename - the name of the file to be deleted
Throws:
XException - if something goes wrong

getFileLength

protected long getFileLength(java.lang.String filename)
Parameters:
filename - name of the file
Returns:
the length of the given file

getLastByteOfFile

protected int getLastByteOfFile(java.lang.String filename)
                         throws XException
Parameters:
filename - name of the file
Returns:
the last byte of the given file
Throws:
XException - if something goes wrong