public abstract class ZFileExtension
extends java.lang.Object
ZFile. Extensions are notified when files are open, updated, closed and
when files are added or removed from the zip. These notifications are received after the zip
has been updated in memory for open, when files are added or removed and when the zip has been
updated on disk or closed.
An extension is also notified before the file is updated, allowing it to modify the file before the update happens. If it does, then all extensions are notified of the changes on the zip file. Because the order of the notifications is preserved, all extensions are notified in the same order. For example, if two extensions E1 and E2 are registered and they both add a file at update time, this would be the flow:
beforeUpdate notification.beforeUpdate notification.
An extension should not modify the zip file when notified of changes. If allowed, this would
break event notification order in case multiple extensions are registered with the zip file.
To allow performing changes to the zip file, all notification method return a
IOExceptionRunnable that is invoked when ZFile has finished notifying all
extensions.
| Constructor and Description |
|---|
ZFileExtension() |
| Modifier and Type | Method and Description |
|---|---|
IOExceptionRunnable |
added(StoredEntry entry,
StoredEntry replaced)
A new entry has been added to the zip, possibly replacing an entry in there.
|
IOExceptionRunnable |
beforeUpdate()
The zip will be updated.
|
void |
closed()
The zip file has been closed.
|
void |
entriesWritten()
This notification is sent when all entries have been written in the file but the central
directory and the EOCD have not yet been written.
|
IOExceptionRunnable |
open()
The zip file has been open and the zip's contents have been read.
|
IOExceptionRunnable |
removed(StoredEntry entry)
An entry has been removed from the zip.
|
void |
updated()
The zip file has been updated on disk.
|
@Nullable public IOExceptionRunnable open() throws java.io.IOException
null.java.io.IOException - failed to process the event@Nullable public IOExceptionRunnable beforeUpdate() throws java.io.IOException
null.
After this notification is received, the extension will receive further
added(StoredEntry, StoredEntry) and removed(StoredEntry) notifications if
it or other extensions add or remove files before update.
When no more files are updated, the entriesWritten() notification is sent.
java.io.IOException - failed to process the eventpublic void entriesWritten()
throws java.io.IOException
After this notification, updated() is sent.
java.io.IOException - failed to process the eventpublic void updated()
throws java.io.IOException
java.io.IOException - failed to perform update taskspublic void closed()
ZFile.close() requires that the zip file
be updated (because it had in-memory changes), updated() will be called before
this method. The default implementation does nothing.@Nullable public IOExceptionRunnable added(@Nonnull StoredEntry entry, @Nullable StoredEntry replaced)
null.entry - the entry that was addedreplaced - the entry that was replaced, if any@Nullable public IOExceptionRunnable removed(@Nonnull StoredEntry entry)
added(StoredEntry, StoredEntry). The default implementation does nothing and
returns null.entry - the entry that was deleted