Package org.cdlib.mrt.utility
Class ArchiveBuilderBase
java.lang.Object
org.cdlib.mrt.utility.ArchiveBuilderBase
- Direct Known Subclasses:
ArchiveBuilderBase.Tar
,ArchiveBuilderBase.Zip
Build an archive (tar, targz, or zip) from a directory
- Author:
- dloy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Archive types available Enum constructor: extension, mimeTypestatic class
Tar archive - with call backs for Tarstatic class
Tar-gunzip archive - with call backs specific to Tarstatic class
Zip archive - with call backs specific to zip -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArchiveBuilderBase.ArchiveType
protected static final int
protected long
protected long
protected boolean
protected static final boolean
protected boolean
protected File
protected boolean
protected LoggerInf
protected static final String
protected static final String
protected OutputStream
protected File
-
Constructor Summary
ConstructorsConstructorDescriptionArchiveBuilderBase
(File fromDir, File toArchive, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) Contructor used as build method for this classArchiveBuilderBase
(File fromDir, OutputStream outputStream, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) Contructor used as build method for this class -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Recursive method for finding files and adding to archiveprotected abstract void
addItemFile
(File entry, LoggerInf logger) Call back routinte to write an archive entry to archive output.void
buildArchive
(boolean includeBase) Create archive from constructor supplied valuesprotected abstract void
Call back routine to close archive.static ArchiveBuilderBase
getArchiveBuilderBase
(File fromDir, File toArchive, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) Factory routine to get specific ArchiveBuilder for supplied ArchiveTypestatic ArchiveBuilderBase
getArchiveBuilderBase
(File fromDir, OutputStream outputStream, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) Factory routine to get specific ArchiveBuilder for supplied ArchiveTypelong
long
static long
static long
getDecimal
(String hex) protected String
getEntryName
(File addFile) Normalize archive entry nameboolean
static void
Main methodprotected ArchiveBuilderBase
setCompressZip
(boolean compressZip) setDeleteFileAfterCopy
(boolean deleteFileAfterCopy) protected void
setEntry
(OutputStream out, File entry) Move file to archiveprotected abstract void
setOutputStream
(OutputStream baseOutputStream) Call back routine for setting archive output stream type: tar, tar.gz, zip
-
Field Details
-
NAME
- See Also:
-
MESSAGE
- See Also:
-
DEBUG
protected static final boolean DEBUG- See Also:
-
BUFSIZE
protected static final int BUFSIZE- See Also:
-
archiveType
-
logger
-
fromDir
-
toArchive
-
outputStream
-
includeBase
protected boolean includeBase -
deleteFileAfterCopy
protected boolean deleteFileAfterCopy -
compressZip
protected boolean compressZip -
buildTimeMs
protected long buildTimeMs -
buildFileCnt
protected long buildFileCnt
-
-
Constructor Details
-
ArchiveBuilderBase
public ArchiveBuilderBase(File fromDir, File toArchive, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException Contructor used as build method for this class- Parameters:
fromDir
- - directory to be archivedtoArchive
- - archive to this filelogger
- - process loggingarchiveType
- type of archive to create see ArchiveType- Throws:
TException
-
ArchiveBuilderBase
public ArchiveBuilderBase(File fromDir, OutputStream outputStream, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException Contructor used as build method for this class- Parameters:
fromDir
- - directory to be archivedtoArchive
- - archive to this filelogger
- - process loggingarchiveType
- type of archive to create see ArchiveType- Throws:
TException
-
-
Method Details
-
getArchiveBuilderBase
public static ArchiveBuilderBase getArchiveBuilderBase(File fromDir, File toArchive, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException Factory routine to get specific ArchiveBuilder for supplied ArchiveType- Parameters:
fromDir
- - directory to be archivedtoArchive
- - archive to this filelogger
- - process loggingarchiveType
- type of archive to create see ArchiveType- Returns:
- specific type of ArchiveBuilder
- Throws:
TException
-
getArchiveBuilderBase
public static ArchiveBuilderBase getArchiveBuilderBase(File fromDir, OutputStream outputStream, LoggerInf logger, ArchiveBuilderBase.ArchiveType archiveType) throws TException Factory routine to get specific ArchiveBuilder for supplied ArchiveType- Parameters:
fromDir
- - directory to be archivedtoArchive
- - archive to this filelogger
- - process loggingarchiveType
- type of archive to create see ArchiveType- Returns:
- specific type of ArchiveBuilder
- Throws:
TException
-
buildArchive
Create archive from constructor supplied values- Throws:
TException
-
setOutputStream
Call back routine for setting archive output stream type: tar, tar.gz, zip- Parameters:
baseOutputStream
-- Throws:
TException
-
addItemFile
Call back routinte to write an archive entry to archive output. Archive type specific.- Parameters:
entry
- archive file entry- Throws:
TException
-
closeArchive
protected abstract void closeArchive()Call back routine to close archive. Archive type specific. -
getEntryName
Normalize archive entry name- Parameters:
addFile
- file used for generating archive name- Returns:
- normalized archive name
- Throws:
TException
-
addFiles
Recursive method for finding files and adding to archive- Parameters:
sourceLocation
- file or directory to archive- Throws:
TException
-
setEntry
Move file to archive- Parameters:
out
- write to this output streamentry
- file to write to output- Throws:
TException
-
getCRC
- Throws:
Exception
-
getDecimal
-
main
Main method -
isDeleteFileAfterCopy
public boolean isDeleteFileAfterCopy() -
setDeleteFileAfterCopy
-
setCompressZip
-
getBuildTimeMs
public long getBuildTimeMs() -
getBuildFileCnt
public long getBuildFileCnt()
-