Package adams.gui.tools.previewbrowser
Class AbstractArchiveHandler
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.tools.previewbrowser.AbstractArchiveHandler
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,ArchiveHandler
,Serializable
- Direct Known Subclasses:
TarArchiveHandler
,ZipArchiveHandler
public abstract class AbstractArchiveHandler extends AbstractOptionHandler implements ArchiveHandler
Ancestor of all archive handlers.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected PlaceholderFile
m_Archive
the archive to extract the files from.protected static Map<String,List<Class>>
m_Relation
the extenstion archive handlers relation.-
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 AbstractArchiveHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
archiveTipText()
Returns the tip text for this property.protected void
checkArchive()
Performs some checks on the archive.void
defineOptions()
Adds options to the internal list of options.protected abstract boolean
doExtract(String archiveFile, File outFile)
Extracts the specified file and saves it locally.boolean
extract(String archiveFile, File outFile)
Extracts the specified file and saves it locally.PlaceholderFile
getArchive()
Returns the current archive.String[]
getFiles()
Returns the files stored in the archive.static String[]
getHandlers()
Returns a list with classnames of handlers.static List<Class>
getHandlersForFile(File file)
Returns the handlers registered for the extension of the specified file.static List<Class>
getHandlersForFile(String filename)
Returns the handlers registered for the extension of the specified file.protected static Map<String,List<Class>>
getRelation()
Returns the extension/handlers relation.static boolean
hasHandler(File file)
Checks whether the specified file is an archive that can be managed.static boolean
hasHandler(String filename)
Checks whether the specified file is an archive that can be managed.protected abstract String[]
listFiles()
Performs actual listing of files.void
setArchive(PlaceholderFile value)
Sets the archive to get the files from.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, 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.gui.tools.previewbrowser.ArchiveHandler
getExtensions
-
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_Archive
protected PlaceholderFile m_Archive
the archive to extract the files from.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setArchive
public void setArchive(PlaceholderFile value)
Sets the archive to get the files from.- Specified by:
setArchive
in interfaceArchiveHandler
- Parameters:
value
- the archive
-
getArchive
public PlaceholderFile getArchive()
Returns the current archive.- Specified by:
getArchive
in interfaceArchiveHandler
- Returns:
- the archive
-
archiveTipText
public String archiveTipText()
Returns the tip text for this property.- Specified by:
archiveTipText
in interfaceArchiveHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
checkArchive
protected void checkArchive()
Performs some checks on the archive.
-
listFiles
protected abstract String[] listFiles()
Performs actual listing of files.- Returns:
- the stored files
-
getFiles
public String[] getFiles()
Returns the files stored in the archive.- Specified by:
getFiles
in interfaceArchiveHandler
- Returns:
- the files
- See Also:
extract(String, File)
-
doExtract
protected abstract boolean doExtract(String archiveFile, File outFile)
Extracts the specified file and saves it locally.- Parameters:
archiveFile
- the file in the archive to extractoutFile
- the local file to store the content in- Returns:
- true if successfully extracted
- See Also:
listFiles()
-
extract
public boolean extract(String archiveFile, File outFile)
Extracts the specified file and saves it locally.- Specified by:
extract
in interfaceArchiveHandler
- Parameters:
archiveFile
- the file in the archive to extractoutFile
- the local file to store the content in- Returns:
- true if successfully extracted
- See Also:
listFiles()
-
getHandlers
public static String[] getHandlers()
Returns a list with classnames of handlers.- Returns:
- the handler classnames
-
getRelation
protected static Map<String,List<Class>> getRelation()
Returns the extension/handlers relation.- Returns:
- the relation
-
hasHandler
public static boolean hasHandler(File file)
Checks whether the specified file is an archive that can be managed.- Parameters:
file
- the file to check- Returns:
- true if the file represents a managed archive
-
hasHandler
public static boolean hasHandler(String filename)
Checks whether the specified file is an archive that can be managed.- Parameters:
filename
- the file to check- Returns:
- true if the file represents a managed archive
-
getHandlersForFile
public static List<Class> getHandlersForFile(File file)
Returns the handlers registered for the extension of the specified file.- Parameters:
file
- the file to get the handlers for- Returns:
- the handlers, null if none available
-
-