Class FileExtractor
java.lang.Object
electrostatic4j.snaploader.filesystem.FileExtractor
- All Implemented Interfaces:
OutputStreamProvider,StreamProvider,AutoCloseable
- Direct Known Subclasses:
ConcurrentFileExtractor
Extracts a filesystem from a zip compression to a destination filesystem.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringAn absolute path for the destination filesystem of the extraction process.protected FileExtractionListenerAn interface object to provide the extraction process with a command-state pattern.protected FileLocatorLocates a filesystem inside a zip compression.protected OutputStreamProvides an output byte stream for this FileExtractor object. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiates an empty filesystem extractor.FileExtractor(FileLocator fileLocator, String destination) Instantiates a filesystem extractor object with a filesystem locator and a destination filesystem. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidextract()Commands and Extract the specified filesystem to the specified destination filesystem.Retrieves the input stream provider object (the filesystem locator object).Retrieves the output stream object associated with this provider.voidinitialize(int size) Initializes the buffered stream handler object.voidsetExtractionListener(FileExtractionListener fileExtractionListener) Sets the extraction listener action to dispatch theFileExtractionListener.onExtractionCompleted(FileExtractor)when the extraction task is completed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface electrostatic4j.snaploader.filesystem.StreamProvider
getHashKey
-
Field Details
-
fileLocator
Locates a filesystem inside a zip compression. -
fileOutputStream
Provides an output byte stream for this FileExtractor object. -
fileExtractionListener
An interface object to provide the extraction process with a command-state pattern. -
destination
An absolute path for the destination filesystem of the extraction process.
-
-
Constructor Details
-
FileExtractor
Instantiates a filesystem extractor object with a filesystem locator and a destination filesystem.- Parameters:
fileLocator- locates a filesystem inside a zip compressiondestination- an absolute filesystem path representing the extraction destination filesystem
-
FileExtractor
protected FileExtractor()Instantiates an empty filesystem extractor.
-
-
Method Details
-
initialize
Description copied from interface:StreamProviderInitializes the buffered stream handler object.- Specified by:
initializein interfaceStreamProvider- Parameters:
size- the size of the buffered IO in bytes or zero for auto filesystem size- Throws:
Exception
-
extract
Commands and Extract the specified filesystem to the specified destination filesystem.Warning: this function leaks buffered streams; this vision was attained for freedom of use, but the user application must keep in mind that stream closure and resources release must be attained either through the extraction completed and failure listeners, or through a try-with resources.
- Throws:
IOException- if the input/output streams has failed or an interrupted I/O operation has occurred.FileNotFoundException- if the file locator has failed to locate the file inside the compression for the extraction process.
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
getFileOutputStream
Description copied from interface:OutputStreamProviderRetrieves the output stream object associated with this provider.- Specified by:
getFileOutputStreamin interfaceOutputStreamProvider- Returns:
- an output stream provider object to extract the filesystem
-
getFileLocator
Description copied from interface:OutputStreamProviderRetrieves the input stream provider object (the filesystem locator object).- Specified by:
getFileLocatorin interfaceOutputStreamProvider- Returns:
- an input stream provider object that is the filesystem locator object
-
setExtractionListener
Sets the extraction listener action to dispatch theFileExtractionListener.onExtractionCompleted(FileExtractor)when the extraction task is completed.- Parameters:
fileExtractionListener- an implementation object of the extraction listener dispatched when the extraction is completed
-