|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.sevenzipjbinding.SevenZip
public class SevenZip
7-Zip-JBinding entry point class. Finds and initializes 7-Zip-JBinding native library. Opens archives and returns
implementation of ISevenZipInArchive
initSevenZipFromPlatformJAR()
method. This initialization process
requires a platform jar to be in a class path. The automatic initialization starts before the first access to an
archive, if native library wasn't already initialized manually with one of the initSevenZip...
methods.
If manual or automatic initialization failed, no further automatic initialization attempts will be made. The
initialization status and error messages can be obtained by following methods:
isInitializedSuccessfully()
- get initialization statusisAutoInitializationWillOccur()
- determine, if an initialization attempt was madegetLastInitializationException()
- get last thrown initialization exceptionsevenzipjbinding-Platform.jar
with one or more native
libraries for respective one or more platforms. Here is some examples of 7-Zip-JBinding platform jar files.
sevenzipjbinding-Linux-i386.jar
with native library for exact one platform: Linux, 32 bitsevenzipjbinding-AllWindows.jar
with native libraries for two platforms: Windows 32 and 64 bitsevenzipjbinding-AllPlatforms.jar
with native libraries for all available platforms/sevenzipjbinding-platforms.properties
file in the class path by calling getPlatformList()
method. The list is cached in a static variable.getPlatformBestMatch()
method. If the list of available platforms
contains exact one platform the platform is always considered the best match. If more, that one platforms are
available to choose from, the system properties os.arch
and os.name
(first part) are used
to make the choice./ChosenPlatform/sevenzipjbinding-lib.properties
in the class path. The list contains names of the
dynamic libraries situated in the /ChosenPlatform/
directory in the same jar.initSevenZipFromPlatformJAR(...)
methods,
the temporary directory is determined using system property java.io.tmpdir
.System.load(String)
method.System.load(String)
or
System.loadLibrary(String)
initLoadedLibraries()
method to initialize manually loaded native libraryAccessController.doPrivileged(java.security.PrivilegedAction)
block. This can be overruled by setting
sevenzip.no_doprivileged_initialization
system property. For example:
java -Dsevenzip.no_doprivileged_initialization=1 ...
createOrVerifyTmpDir(File)
:
tmpDirectory
parameter of
initSevenZipFromPlatformJAR(File)
or initSevenZipFromPlatformJAR(String, File)
it will be used
java.io.tmpdir
get used
java.io.tmpdir
isn't set, an exception get raised
getTemporaryArtifacts()
. By default,
7-Zip-JBinding doesn't delete those artifacts trying to reduce subsequent initialization overhead. If 7-Zip-JBinding
finds the native libraries within the temporary directory, it uses those without further verification. In order to
allow smoothly updates, the temporary sub-directory with the native libraries named with a unique build reference
number. If 7-Zip-JBinding get updated, a new temporary sub-directory get created and the new native libraries get
copied and used.
openInArchive(ArchiveFormat, IInStream)
- simple open archive method.openInArchive(ArchiveFormat, IInStream, IArchiveOpenCallback)
- generic open archive method. It's
possible to open all kinds of archives providing call back object that implements following interfaces
IArchiveOpenCallback
- base interface. Must be implemented by all call back classesICryptoGetTextPassword
- (optional) Provides password encrypted indexIArchiveOpenVolumeCallback
- (optional) Provides information about volumes in multipart archives.
Currently used only for multipart RAR
archives. For opening multipart 7z
archives use
VolumedArchiveInStream
.openInArchive(ArchiveFormat, IInStream, String)
a shortcut method for opening archives with an encrypted
index.
Method Summary | |
---|---|
static java.lang.Throwable |
getLastInitializationException()
Returns last native library initialization exception, if occurs. |
static java.util.List<java.lang.String> |
getPlatformList()
Load list of the available platforms out of sevenzipjbinding-Platform.jar in the class path. |
static java.io.File[] |
getTemporaryArtifacts()
Returns list of the temporary created artifacts (one directory and one or more files within this directory). |
static java.lang.String |
getUsedPlatform()
Return the platform used for the initialization. |
static void |
initLoadedLibraries()
Initialize 7-Zip-JBinding native library without loading libraries in JVM first. |
static void |
initSevenZipFromPlatformJAR()
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static void |
initSevenZipFromPlatformJAR(java.io.File tmpDirectory)
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static void |
initSevenZipFromPlatformJAR(java.lang.String platform)
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static void |
initSevenZipFromPlatformJAR(java.lang.String platform,
java.io.File tmpDirectory)
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static boolean |
isAutoInitializationWillOccur()
Returns weather automatic initialization will occur or not. |
static boolean |
isInitializedSuccessfully()
Tests native library initialization status of SevenZipJBinding. |
static ISevenZipInArchive |
openInArchive(ArchiveFormat archiveFormat,
IInStream inStream)
Open archive of type archiveFormat from the input stream inStream . |
static ISevenZipInArchive |
openInArchive(ArchiveFormat archiveFormat,
IInStream inStream,
IArchiveOpenCallback archiveOpenCallback)
Open archive of type archiveFormat from the input stream inStream using 'archive open
call back' listener archiveOpenCallback . |
static ISevenZipInArchive |
openInArchive(ArchiveFormat archiveFormat,
IInStream inStream,
java.lang.String passwordForOpen)
Open archive of type archiveFormat from the input stream inStream using 'archive open
call-back' listener archiveOpenCallback . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isInitializedSuccessfully()
getLastInitializationException()
method to get more information in case of initialization failure.
true
7-Zip-JBinding native library was initialized successfully. Native library wasn't
initialized successfully (yet).getLastInitializationException()
,
isAutoInitializationWillOccur()
public static java.lang.Throwable getLastInitializationException()
null
- no initialization exception occurred (yet), else initialization exceptionisInitializedSuccessfully()
public static boolean isAutoInitializationWillOccur()
initSevenZip...
methods. If manual or automatic initialization failed, no further automatic initialization attempts will be made.
true
automatic initialization will occur, false
automatic initialization will
not occurisInitializedSuccessfully()
,
getLastInitializationException()
public static java.lang.String getUsedPlatform()
getPlatformList()
.
null
if initialization wasn't performed yet.getPlatformList()
public static java.util.List<java.lang.String> getPlatformList() throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
in the class path.
SevenZipNativeInitializationException
- indicated problems finding or parsing platform property filepublic static java.io.File[] getTemporaryArtifacts()
File
s.public static void initSevenZipFromPlatformJAR() throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR(File)
,
initSevenZipFromPlatformJAR(String)
,
initSevenZipFromPlatformJAR(String, File)
public static void initSevenZipFromPlatformJAR(java.io.File tmpDirectory) throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
tmpDirectory
- temporary directory to copy native libraries to. This directory must be writable and contain at least
2 MB free space.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR()
,
initSevenZipFromPlatformJAR(String)
,
initSevenZipFromPlatformJAR(String, File)
public static void initSevenZipFromPlatformJAR(java.lang.String platform, java.io.File tmpDirectory) throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
tmpDirectory
- temporary directory to copy native libraries to. This directory must be writable and contain at least
2 MB free space.platform
- Platform to load native library for. The platform must be one of the elements of the list of available
platforms returned by getPlatformList()
.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR()
,
initSevenZipFromPlatformJAR(File)
,
initSevenZipFromPlatformJAR(String)
,
getPlatformList()
public static void initSevenZipFromPlatformJAR(java.lang.String platform) throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
platform
- Platform to load native library for. The platform must be one of the elements of the list of available
platforms returned by getPlatformList()
.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR()
,
initSevenZipFromPlatformJAR(File)
,
initSevenZipFromPlatformJAR(String, File)
,
getPlatformList()
public static void initLoadedLibraries() throws SevenZipNativeInitializationException
SevenZipNativeInitializationException
public static ISevenZipInArchive openInArchive(ArchiveFormat archiveFormat, IInStream inStream, IArchiveOpenCallback archiveOpenCallback) throws SevenZipException
archiveFormat
from the input stream inStream
using 'archive open
call back' listener archiveOpenCallback
. To open archive from the file, use
RandomAccessFileInStream
.
archiveFormat
- format of archiveinStream
- input stream to open archive fromarchiveOpenCallback
- archive open call back listener to use. You can optionally implement ICryptoGetTextPassword
to
specify password to use.
ISevenZipInArchive
which represents opened archive.
SevenZipException
- 7-Zip or 7-Zip-JBinding intern error occur. Check exception message for more information.
java.lang.NullPointerException
- is thrown, if inStream is nullopenInArchive(ArchiveFormat, IInStream, IArchiveOpenCallback)
,
openInArchive(ArchiveFormat, IInStream, String)
public static ISevenZipInArchive openInArchive(ArchiveFormat archiveFormat, IInStream inStream, java.lang.String passwordForOpen) throws SevenZipException
archiveFormat
from the input stream inStream
using 'archive open
call-back' listener archiveOpenCallback
. To open archive from the file, use
RandomAccessFileInStream
.
archiveFormat
- format of archiveinStream
- input stream to open archive frompasswordForOpen
- password to use. Warning: this password will not be used to extract item from archive but only to open
archive. (7-zip format supports encrypted filename)
ISevenZipInArchive
which represents opened archive.
SevenZipException
- 7-Zip or 7-Zip-JBinding intern error occur. Check exception message for more information.
java.lang.NullPointerException
- is thrown, if inStream is nullopenInArchive(ArchiveFormat, IInStream)
,
openInArchive(ArchiveFormat, IInStream, IArchiveOpenCallback)
public static ISevenZipInArchive openInArchive(ArchiveFormat archiveFormat, IInStream inStream) throws SevenZipException
archiveFormat
from the input stream inStream
. To open archive from
the file, use RandomAccessFileInStream
.
archiveFormat
- (optional) format of archive. If null
archive format will be auto-detected.inStream
- input stream to open archive from
ISevenZipInArchive
which represents opened archive.
SevenZipException
- 7-Zip or 7-Zip-JBinding intern error occur. Check exception message for more information.
java.lang.NullPointerException
- is thrown, if inStream is nullopenInArchive(ArchiveFormat, IInStream)
,
openInArchive(ArchiveFormat, IInStream, String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |