Class FileLocator
java.lang.Object
electrostatic4j.snaploader.filesystem.FileLocator
- All Implemented Interfaces:
InputStreamProvider,StreamProvider,ZipStreamProvider,AutoCloseable
- Direct Known Subclasses:
LibraryLocator
An Input Stream Provider that locates a filesystem inside a zip compression and provides an
input stream object for the located filesystem entry.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ZipFileResembles the compression stream provider object, used in the case of external compression routines.protected InputStreamThe input stream associated with the located filesystem.protected FileLocalizingListenerAn interface object to provide the file-localizing process with a command-state pattern; binding the user application interface with the file localizing lifecycle.protected StringResembles the file path inside the compression. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiates an empty filesystem locator object.FileLocator(String filePath) Locates the library inside the stock jar filesystem.FileLocator(ZipFile compression, String filePath) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCommands for the classpath routines.voidclose()protected voidexternalCompressionRoutine(int size) Commands for the external compression routines.Retrieves the compression used to locate the files.Retrieves the input stream object associated with this filesystem entry.voidinitialize(int size) Initializes the input stream provider through a file locator routine, either classpath routine or external archive routine.voidsetFileLocalizingListener(FileLocalizingListener fileLocalizingListener) Sets the file localizing listener interface object to bind the user application to the file localizing lifecycle.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
-
fileInputStream
The input stream associated with the located filesystem. -
fileLocalizingListener
An interface object to provide the file-localizing process with a command-state pattern; binding the user application interface with the file localizing lifecycle. -
compression
Resembles the compression stream provider object, used in the case of external compression routines. -
filePath
Resembles the file path inside the compression.
-
-
Constructor Details
-
FileLocator
Locates the library inside the stock jar filesystem.- Parameters:
filePath- the path to the dynamic native library inside that jar filesystem
-
FileLocator
Locates a filesystem inside an external zip compression, the zip filesystem is defined as aZipFileobject and the locatable filesystem is defined as aZipEntryobject.- Parameters:
compression- the compression, eitherZipFileorJarFilefilePath- the path to the filesystem inside the compression to be extracted- Throws:
IOException- if the jar to be located is not found or an interrupted I/O exception has occurred
-
FileLocator
protected FileLocator()Instantiates an empty filesystem locator object.
-
-
Method Details
-
initialize
Initializes the input stream provider through a file locator routine, either classpath routine or external archive routine.Warning: this stack leaks an input stream provider object for the file to be extracted, and the external archive stream provider in case of using an external archive routine to locate the file.
- Specified by:
initializein interfaceStreamProvider- Parameters:
size- the size of the buffered IO in bytes or zero for auto filesystem size- Throws:
IOException- if an I/O error has occurred.
-
classPathRoutine
Commands for the classpath routines.- Throws:
FilesystemResourceInitializationException- if the classpath routine fails to locate the file.
-
externalCompressionRoutine
Commands for the external compression routines.- Parameters:
size- custom buffer size, zero for auto filesystem size (warning: file expansion and truncation rules are applied).- Throws:
IOException- if an I/O error has occurred.
-
getFileInputStream
Description copied from interface:InputStreamProviderRetrieves the input stream object associated with this filesystem entry.- Specified by:
getFileInputStreamin interfaceInputStreamProvider- Returns:
- an input stream object for this located filesystem
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
setFileLocalizingListener
Description copied from interface:InputStreamProviderSets the file localizing listener interface object to bind the user application to the file localizing lifecycle.- Specified by:
setFileLocalizingListenerin interfaceInputStreamProvider- Parameters:
fileLocalizingListener- an implementation object of the file localizing listener
-
getCompression
Description copied from interface:ZipStreamProviderRetrieves the compression used to locate the files.- Specified by:
getCompressionin interfaceZipStreamProvider- Returns:
- a zip filesystem object
-