com.lightdev.app.fileserver.http
Class FileSystemSerialiser

java.lang.Object
  extended by com.lightdev.app.fileserver.http.FileSystemSerialiser

public class FileSystemSerialiser
extends Object

Class FileSystemSerialiser transforms objects of the Light Development File System library to and from byte arrays.

It wraps an instance of class LocalFileSystem and exposes its methods as methods of same name but with 'neutral' signatures. I.e. method arguments and return values are deserialised from and serialised to byte arrays. Objects exchanged by class LocalFileSystem can be used across different instances of the Java virtual machine this way.

Version:
2, 6.3.2008
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software
See Also:
LocalFileSystem

Constructor Summary
FileSystemSerialiser()
          create a new instance of class FileServer
 
Method Summary
 boolean copy(byte[] filesToCopy, byte[] toDirectory)
          copy files to a given folder.
 boolean createFolder(byte[] folder)
          create a new folder
 boolean delete(byte[] filesToDelete)
          delete one or more files
 boolean extract(byte[] archive, byte[] toFolder)
          extract a given ZIP archive to a given folder
 boolean fileExists(byte[] file)
          determine whether or not a given file exists in this instance of file system
 byte[] getFileSeparator()
          get the string that is used to separate file and folder names in path expressions for the machine this file system refers to
 double getFolderSize(byte[] folder)
          determine the size of a folder in bytes
 byte[] getParentFile(byte[] file)
          get the file that is directly on top of a given file in the file hierarchy of this file system
 byte[] getRoots()
          get the root directories of this file system
 double getSize(byte[] files)
           
 byte[] getUrl()
          get the url string of the machine this file system is located at
 byte[] list(byte[] directory)
          get the files that are contained in a given folder
 boolean move(byte[] source, byte[] dest)
          move one or more files to a given folder.
 boolean pack(byte[] folder, byte[] archive)
          pack the contents of a given folder into a new ZIP compressed archive
 byte[] read(byte[] file)
          read contents of a file
 byte[] rename(byte[] file, byte[] newName)
          rename a file, i.e. change the name of a file but not its location
 boolean write(byte[] file, byte[] contents)
          write contents of a file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemSerialiser

public FileSystemSerialiser()
create a new instance of class FileServer

Method Detail

getParentFile

public byte[] getParentFile(byte[] file)
                     throws Exception
get the file that is directly on top of a given file in the file hierarchy of this file system

Parameters:
file - byte[] a byte array of type FileRef referencing the file to get the parent of
Returns:
byte[] the byte array of type FileRef with the parent file
Throws:
Exception

list

public byte[] list(byte[] directory)
            throws Exception
get the files that are contained in a given folder

Parameters:
directory - byte[] of type FileRef referencing the folder to get a list of files of
Returns:
byte[] byte array of type FileRef[] with the list of files in the given folder
Throws:
Exception

getRoots

public byte[] getRoots()
                throws Exception
get the root directories of this file system

Returns:
byte[] byte array of type FileRef[] with the list of root file references
Throws:
Exception

getFileSeparator

public byte[] getFileSeparator()
                        throws Exception
get the string that is used to separate file and folder names in path expressions for the machine this file system refers to

Returns:
the separator string as a byte array
Throws:
Exception

copy

public boolean copy(byte[] filesToCopy,
                    byte[] toDirectory)
             throws Exception
copy files to a given folder.

Parameters:
filesToCopy - byte array of type FileRef[] with the files to copy
toDirectory - byte array of type FileRef with the directory to copy to
Throws:
Exception

rename

public byte[] rename(byte[] file,
                     byte[] newName)
              throws Exception
rename a file, i.e. change the name of a file but not its location

Parameters:
file - byte array of type FileRef with the file to rename
newName - byte array of type String with the new name; just the name, no path
Throws:
Exception

move

public boolean move(byte[] source,
                    byte[] dest)
             throws Exception
move one or more files to a given folder.

Parameters:
source - byte array of type fileRef[] with the files to move
dest - byte array of type FileRef with the folder to move to
Throws:
Exception

delete

public boolean delete(byte[] filesToDelete)
               throws Exception
delete one or more files

Parameters:
filesToDelete - byte array of type FileRef[] with the list of files to delete
Throws:
Exception

pack

public boolean pack(byte[] folder,
                    byte[] archive)
             throws Exception
pack the contents of a given folder into a new ZIP compressed archive

Parameters:
folder - byte array of type FileRef with the folder to pack
archive - byte array of type FileRef with the archive to create from the given files
Throws:
Exception

extract

public boolean extract(byte[] archive,
                       byte[] toFolder)
                throws Exception
extract a given ZIP archive to a given folder

Parameters:
archive - byte array of type FileRef with the archive to extract
toFolder - byte array of type FileRef with the folder to extract the contents of the archive to
Throws:
Exception

createFolder

public boolean createFolder(byte[] folder)
                     throws Exception
create a new folder

Parameters:
folder - byte array of type FileRef with the folder to create
Throws:
Exception

fileExists

public boolean fileExists(byte[] file)
                   throws Exception
determine whether or not a given file exists in this instance of file system

Parameters:
file - byte array of type FileRef with the file to determine existence for
Returns:
true if the given files exists in this instance of file system, false if not
Throws:
Exception

getFolderSize

public double getFolderSize(byte[] folder)
                     throws Exception
determine the size of a folder in bytes

Parameters:
folder - byte array of type FileRef with the folder to determine the size for
Returns:
the size of the folder in bytes
Throws:
Exception

getSize

public double getSize(byte[] files)
               throws Exception
Throws:
Exception

getUrl

public byte[] getUrl()
              throws Exception
get the url string of the machine this file system is located at

Returns:
byte array of type String with the url string of machine this file system is located
Throws:
Exception

read

public byte[] read(byte[] file)
            throws Exception
read contents of a file

Parameters:
file - byte array of type FileRef with the reference to the file to read
Returns:
the file contents
Throws:
Exception

write

public boolean write(byte[] file,
                     byte[] contents)
              throws Exception
write contents of a file

Parameters:
file - byte array of type FileRef with the reference to the file to write
contents - the contents to write to the referenced file
Throws:
Exception