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 intm_BufferSizethe buffer size to use.protected FileOutputStreamm_FileOutthe file output stream for the zip archive.protected org.apache.commons.compress.archivers.zip.ZipArchiveOutputStreamm_ZipOutthe 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 Stringadd(byte[] data, String name)Adds the data to the archive.Stringadd(PlaceholderFile data, String name)Adds the file to the archive.Stringadd(InputStream data, String name)Adds the data from the input stream to the archive.StringbufferSizeTipText()Returns the tip text for this property.Stringclose()Finalizes the archive.voiddefineOptions()Adds options to the internal list of options.intgetBufferSize()Returns the buffer size for the stream.StringgetQuickInfo()Returns a quick info about the object, which can be displayed in the GUI.StringglobalInfo()Returns a string describing the object.Stringinitialize(PlaceholderFile output)Initializes the archive.voidsetBufferSize(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:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin 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:
getQuickInfoin interfaceQuickInfoSupporter- Returns:
- null if no info available, otherwise short string
-
initialize
public String initialize(PlaceholderFile output)
Initializes the archive.- Specified by:
initializein 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:
addin 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:
addin 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:
addin 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:
closein interfaceArchiveManager- Returns:
- null if successful, otherwise error message
-
-