Package adams.core.io
Class TarArchiveManager
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.io.TarArchiveManager
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,ArchiveManager
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,Serializable
public class TarArchiveManager extends AbstractOptionHandler implements ArchiveManager
Manages tar files.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_BufferSize
the buffer size to use.protected TarUtils.Compression
m_Compression
the compression to use.protected FileOutputStream
m_FileOut
the file output stream for the tar archive.protected org.apache.commons.compress.archivers.tar.TarArchiveOutputStream
m_TarOut
the tar archive stream.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description TarArchiveManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
add(byte[] data, String name)
Adds the data to the archive.String
add(PlaceholderFile data, String name)
Adds the file to the archive.String
add(InputStream data, String name)
Adds the data from the input stream to the archive.String
bufferSizeTipText()
Returns the tip text for this property.String
close()
Finalizes the archive.String
compressionTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.int
getBufferSize()
Returns the buffer size for the stream.TarUtils.Compression
getCompression()
Returns the compression to use.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.String
globalInfo()
Returns a string describing the object.String
initialize(PlaceholderFile output)
Initializes the archive.void
setBufferSize(int value)
Sets the buffer size for the stream.void
setCompression(TarUtils.Compression value)
Sets the compression to use.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_Compression
protected TarUtils.Compression m_Compression
the compression to use.
-
m_BufferSize
protected int m_BufferSize
the buffer size to use.
-
m_TarOut
protected transient org.apache.commons.compress.archivers.tar.TarArchiveOutputStream m_TarOut
the tar archive stream.
-
m_FileOut
protected transient FileOutputStream m_FileOut
the file output stream for the tar archive.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setCompression
public void setCompression(TarUtils.Compression value)
Sets the compression to use. IfTarUtils.Compression.AUTO
then compression gets determined based on file extension.- Parameters:
value
- the compression to use
-
getCompression
public TarUtils.Compression getCompression()
Returns the compression to use. IfTarUtils.Compression.AUTO
then compression gets determined based on file extension.- Returns:
- the compression to use
-
compressionTipText
public String compressionTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBufferSize
public void setBufferSize(int value)
Sets the buffer size for the stream.- Parameters:
value
- the size in bytes
-
getBufferSize
public int getBufferSize()
Returns the buffer size for the stream.- Returns:
- the size in bytes
-
bufferSizeTipText
public String bufferSizeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
initialize
public String initialize(PlaceholderFile output)
Initializes the archive.- Specified by:
initialize
in interfaceArchiveManager
- Parameters:
output
- the file name for the archive- Returns:
- null if successful, otherwise error message
-
add
public String add(PlaceholderFile data, String name)
Adds the file to the archive.- Specified by:
add
in interfaceArchiveManager
- Parameters:
data
- the file to addname
- the name for the file in the archive- Returns:
- null if successful, otherwise error message
-
add
public String add(InputStream data, String name)
Adds the data from the input stream to the archive. Caller needs to close input stream.- Specified by:
add
in interfaceArchiveManager
- Parameters:
data
- the data to addname
- the name for the data in the archive- Returns:
- null if successful, otherwise error message
-
add
public String add(byte[] data, String name)
Adds the data to the archive.- Specified by:
add
in interfaceArchiveManager
- Parameters:
data
- the data to addname
- the name for the data in the archive- Returns:
- null if successful, otherwise error message
-
close
public String close()
Finalizes the archive.- Specified by:
close
in interfaceArchiveManager
- Returns:
- null if successful, otherwise error message
-
-