ArchiverNULL

public abstract class ArchiverNULL implements Archiver

An ArchiverNULL is a null packaging device that provides some useful method for the sub-class which enhance code design and ease to read.

  • Pre-error Handling of compress,list and extract

Creation Date: 13/11/2006

Author:Twinsen Tsang

Methods

compress

public boolean compress(File src, File dest, boolean includeItself)

The NULL archiver validates all fields in the parameters and return false in the end.

Parameters:
  • src – The source of the file(s) to be archive.
  • dest – The destination of the arhived file.
  • includeItself – the source directory includes in the archive if it is true, vice versa.
Throws:
  • IOException – if any kind of I/O Erros
Returns:

true if the operations run successfully.

See also: hk.hku.cecid.edi.sfrm.archive.Archiver.compress(File,File,boolean)

extract

public boolean extract(File archive, File dest)

The NULL archiver validates all fields in the parameters and return false in the end. If the destination directory does not exist, the NULL archiver will create one for you.

Parameters:
  • archive – The archive to be extract.
  • dest – The destination directory extract to.
Throws:
Returns:

true if the operations run successfully.

getBaseArchivingDirectory

protected String getBaseArchivingDirectory(File src, boolean includeItself)

Get the base directory for archiving. The base directory is the path that all archive entry relative to it. NOTE: This method should only be used inside the compress method.

Returns:the base directory.

listAllToArchive

protected Iterator listAllToArchive(File src)

listAsFile

public List listAsFile(File archive)

List the files inside the archive.

Parameters:
  • archive – The archive to be listed.
Throws:
  • IOException – if any kind of I/O Errors.
Returns:

A list of java.io.File object that represents each entry in the archive.

listAsFilename

public List listAsFilename(File archive)

List the files inside the archive.

Parameters:
  • archive – The archive to be listed.
Throws:
  • IOException – Any kind of I/O Errors.
Returns:

A list of String objects that represents the filename of each entry in the archive.

listFilesToArchive

protected Iterator listFilesToArchive(File src)

List out all files that need to be archive in a compress(File,File,boolean) call. NOTE: This method should only be used inside the compress method.

Parameters:
  • src – The source of the file(s) to be archive.
Returns:

An iterator whichs contains a list of files object to archive.