Package adams.core.io
Class ZipArchiveManager
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.io.ZipArchiveManager
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,ArchiveManager
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,Serializable
public class ZipArchiveManager extends AbstractOptionHandler implements ArchiveManager
Manages zip 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 FileOutputStream
m_FileOut
the file output stream for the zip archive.protected org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
m_ZipOut
the zip 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 ZipArchiveManager()
-
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.void
defineOptions()
Adds options to the internal list of options.int
getBufferSize()
Returns the buffer size for the stream.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.-
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_BufferSize
protected int m_BufferSize
the buffer size to use.
-
m_ZipOut
protected transient org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream m_ZipOut
the zip archive stream.
-
m_FileOut
protected transient FileOutputStream m_FileOut
the file output stream for the zip 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
-
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
-
-