Class LibraryInfo

java.lang.Object
electrostatic4j.snaploader.LibraryInfo

public final class LibraryInfo extends Object
Provides a platform-independent library placeholder with an adjustable baseName baseName grouping the common components among all platforms.

Understand the API vision: The native dynamic API is composed of NativeDynamicLibrary which represents the platform-dependent entity and the LibraryInfo which represents the abstract platform-independent entity; the common components among them represent a backup on the LibraryInfo side that the API will fall back to in case the platform directory path is invalid.

  • ------------------------------
  • (2).Abstract: LibraryInfo (Grouping common components among all platforms; thus platform-independent).
  • ------------------------------
  • (1).Concrete: NativeDynamicLibrary (Grouping platform-dependent components).
  • ------------------------------

where (1).(2) designates the runtime order.

  • Constructor Details

    • LibraryInfo

      public LibraryInfo(DirectoryPath directory, String baseName, DirectoryPath directoryPath)
      Instantiates a library info data structure pointing to a library in the classpath.
      Parameters:
      directory - the platform-independent directory inside the compression used for locating the native dynamic library, this is used as a backup directory path in case the NativeDynamicLibrary.getPlatformDirectory() is not valid.
      baseName - the library basename, for example, 'lib-basename.so' (not null).
      directoryPath - the extraction destination path, DirectoryPath.USER_DIR for a user working directory extraction path, and DirectoryPath.USER_HOME for the user home (not null).
    • LibraryInfo

      public LibraryInfo(DirectoryPath jarPath, DirectoryPath directory, String baseName, DirectoryPath directoryPath)
      Instantiates a library info data structure pointing to a library in an external jar with jarPath.
      Parameters:
      jarPath - a path to an external jar to locate the library inside, DirectoryPath.CLASS_PATH to assign the classpath routine to the FileLocator API (not null).
      directory - the platform-independent directory inside the compression used for locating the native dynamic library, this is used as a backup directory path in case the NativeDynamicLibrary.getPlatformDirectory() is not valid.
      baseName - the library basename, for example, 'lib-basename.so' (not null).
      directoryPath - the extraction destination path, DirectoryPath.USER_DIR for a user working directory extraction path, and DirectoryPath.USER_HOME for the user home (not null).
  • Method Details

    • getBaseName

      public String getBaseName()
      Retrieves the dynamic library basename.
      Returns:
      the library base-name in string (non-null)
    • getJarPath

      public DirectoryPath getJarPath()
      Retrieves the jar filesystem path, the jar is the compression used to locate the native dynamic library to be extracted and loaded by NativeBinaryLoader.
      Returns:
      the jar absolute filesystem path object.
    • getDirectory

      public DirectoryPath getDirectory()
      Retrieves the directory inside the compression used for locating the native dynamic library.
      Returns:
      the path to the dynamic library filesystem inside the compression.
    • getExtractionDirectory

      public DirectoryPath getExtractionDirectory()
      Retrieves the extraction absolute directory.
      Returns:
      the extraction destination path object.
    • setJarPath

      public void setJarPath(DirectoryPath jarPath)
      Sets the absolute path to the jar filesystem to locate the native dynamic library to be extracted and loaded, "null" to use the "classpath (the stock jar)"" to load the library filesystem.
      Parameters:
      jarPath - the external jar path object to localize the compression, use DirectoryPath.CLASS_PATH to switch the file locator to the classpath routine.
    • setDirectory

      public void setDirectory(DirectoryPath directory)
      Sets the directory to the native dynamic library inside the jar compression, "null" to use the default directories specified for each variant by NativeBinaryLoader.
      Parameters:
      directory - the location to the native dynamic library inside the jar compression.
    • setBaseName

      public void setBaseName(String baseName)
      Adjusts the library base name in a dynamic library name (lib-[basename]).
      Parameters:
      baseName - a new base-name to assign (non-null)
    • setExtractionDirectory

      public void setExtractionDirectory(DirectoryPath directoryPath)
      Sets the extraction directory used for extracting the native dynamic library.
      Parameters:
      directoryPath - the extraction directory path to which the native-located library will be extracted to.