Top Description Inners Fields Constructors Methods
org.apache.commons.compress.changes

public Class ChangeSetPerformer<I extends org.apache.commons.compress.archivers.ArchiveInputStream<E>, O extends org.apache.commons.compress.archivers.ArchiveOutputStream<E>, E extends org.apache.commons.compress.archivers.ArchiveEntry>

extends Object
Class Inheritance
Type Parameters
<I>
The ArchiveInputStream type.
<O>
The ArchiveOutputStream type.
<E>
The ArchiveEntry type, must be compatible between the input I and output O stream types.
Imports
java.io.IOException, .InputStream, java.util.Enumeration, .Iterator, .LinkedHashSet, .Set, org.apache.commons.compress.archivers.ArchiveEntry, .ArchiveInputStream, .ArchiveOutputStream, org.apache.commons.compress.archivers.zip.ZipArchiveEntry, .ZipFile, org.apache.commons.compress.changes.Change.ChangeType

Performs ChangeSet operations on a stream. This class is thread safe and can be used multiple times. It operates on a copy of the ChangeSet. If the ChangeSet changes, a new Performer must be created.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
ChangeSetPerformer.ArchiveEntryIterator<E extends ArchiveEntry>

Abstracts getting entries and streams for archive entries.

private static class
private static class

Field Summary

Modifier and TypeField and Description
private final Set<Change<E>>

Constructor Summary

AccessConstructor and Description
public
ChangeSetPerformer(final ChangeSet<E>
the ChangeSet which operations are used for performing
changeSet
)

Constructs a ChangeSetPerformer with the changes from this ChangeSet

Method Summary

Modifier and TypeMethod and Description
private void
copyStream(final InputStream
the stream to read the data from
inputStream
,
final O
the stream to write the data to
outputStream
,
final E
the entry to write
archiveEntry
)

Copies the ArchiveEntry to the Output stream

private boolean

Returns:

true, if this entry has a deletion change later, false otherwise
isDeletedLater
(final Set<Change<E>> workingSet, final E
the entry to check
entry
)

Checks if an ArchiveEntry is deleted later in the ChangeSet.

private ChangeSetResults

Returns:

the results of this operation
perform
(final ChangeSetPerformer.ArchiveEntryIterator<E>
the entries to perform the changes on
entryIterator
,
final O
the resulting OutputStream with all modifications
outputStream
)

Performs all changes collected in this ChangeSet on the input entries and streams the result to the output stream.

public ChangeSetResults

Returns:

the results of this operation
perform
(final I
the InputStream to perform the changes on
inputStream
,
final O
the resulting OutputStream with all modifications
outputStream
)

Performs all changes collected in this ChangeSet on the input stream and streams the result to the output stream.

public ChangeSetResults

Returns:

the results of this operation
perform
(final ZipFile
the ZipFile to perform the changes on
zipFile
,
final O
the resulting OutputStream with all modifications
outputStream
)

Performs all changes collected in this ChangeSet on the ZipFile and streams the result to the output stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changesback to summary
private final Set<Change<E>> changes

Constructor Detail

ChangeSetPerformerback to summary
public ChangeSetPerformer(final ChangeSet<E> changeSet)

Constructs a ChangeSetPerformer with the changes from this ChangeSet

Parameters
changeSet:ChangeSet<E>

the ChangeSet which operations are used for performing

Method Detail

copyStreamback to summary
private void copyStream(final InputStream inputStream, final O outputStream, final E archiveEntry) throws IOException

Copies the ArchiveEntry to the Output stream

Parameters
inputStream:InputStream

the stream to read the data from

outputStream:O

the stream to write the data to

archiveEntry:E

the entry to write

Exceptions
IOException:
if data cannot be read or written
isDeletedLaterback to summary
private boolean isDeletedLater(final Set<Change<E>> workingSet, final E entry)

Checks if an ArchiveEntry is deleted later in the ChangeSet. This is necessary if a file is added with this ChangeSet, but later became deleted in the same set.

Parameters
entry:E

the entry to check

Returns:boolean

true, if this entry has a deletion change later, false otherwise

performback to summary
private ChangeSetResults perform(final ChangeSetPerformer.ArchiveEntryIterator<E> entryIterator, final O outputStream) throws IOException

Performs all changes collected in this ChangeSet on the input entries and streams the result to the output stream. This method finishes the stream, no other entries should be added after that.

Parameters
entryIterator:ChangeSetPerformer.ArchiveEntryIterator<E>

the entries to perform the changes on

outputStream:O

the resulting OutputStream with all modifications

Returns:ChangeSetResults

the results of this operation

Exceptions
IOException:
if a read/write error occurs
performback to summary
public ChangeSetResults perform(final I inputStream, final O outputStream) throws IOException

Performs all changes collected in this ChangeSet on the input stream and streams the result to the output stream. Perform may be called more than once. This method finishes the stream, no other entries should be added after that.

Parameters
inputStream:I

the InputStream to perform the changes on

outputStream:O

the resulting OutputStream with all modifications

Returns:ChangeSetResults

the results of this operation

Exceptions
IOException:
if a read/write error occurs
performback to summary
public ChangeSetResults perform(final ZipFile zipFile, final O outputStream) throws IOException

Performs all changes collected in this ChangeSet on the ZipFile and streams the result to the output stream. Perform may be called more than once. This method finishes the stream, no other entries should be added after that.

Parameters
zipFile:ZipFile

the ZipFile to perform the changes on

outputStream:O

the resulting OutputStream with all modifications

Returns:ChangeSetResults

the results of this operation

Exceptions
IOException:
if a read/write error occurs
Since
1.5
org.apache.commons.compress.changes back to summary

private Interface ChangeSetPerformer.ArchiveEntryIterator<E extends org.apache.commons.compress.archivers.ArchiveEntry>

Known Direct Implementers
org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveInputStreamIterator, org.apache.commons.compress.changes.ChangeSetPerformer.ZipFileIterator

Abstracts getting entries and streams for archive entries.

Iterator#hasNext is not allowed to throw exceptions that's why we can't use Iterator<ArchiveEntry> directly - otherwise we'd need to convert exceptions thrown in ArchiveInputStream#getNextEntry.

Method Summary

Modifier and TypeMethod and Description
public InputStream
public boolean
public E
next()

Method Detail

getInputStreamback to summary
public InputStream getInputStream() throws IOException
hasNextback to summary
public boolean hasNext() throws IOException
nextback to summary
public E next()
org.apache.commons.compress.changes back to summary

private final Class ChangeSetPerformer.ArchiveInputStreamIterator<E extends org.apache.commons.compress.archivers.ArchiveEntry>

extends Object
implements ChangeSetPerformer.ArchiveEntryIterator<E extends ArchiveEntry>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveInputStreamIterator
All Implemented Interfaces
org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator

Field Summary

Modifier and TypeField and Description
private final ArchiveInputStream<E>
private E

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public InputStream
public boolean
public E
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

inputStreamback to summary
private final ArchiveInputStream<E> inputStream
nextback to summary
private E next

Constructor Detail

ArchiveInputStreamIteratorback to summary
pack-priv ArchiveInputStreamIterator(final ArchiveInputStream<E> inputStream)

Method Detail

getInputStreamback to summary
public InputStream getInputStream()

Implements org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator.getInputStream.

Annotations
@Override
hasNextback to summary
public boolean hasNext() throws IOException

Implements org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator.hasNext.

Annotations
@Override
nextback to summary
public E next()

Implements org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator.next.

Annotations
@Override
org.apache.commons.compress.changes back to summary

private final Class ChangeSetPerformer.ZipFileIterator

extends Object
implements ChangeSetPerformer.ArchiveEntryIterator<ZipArchiveEntry>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.changes.ChangeSetPerformer.ZipFileIterator
All Implemented Interfaces
org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator

Field Summary

Modifier and TypeField and Description
private ZipArchiveEntry
private final Enumeration<ZipArchiveEntry>
private final ZipFile

Constructor Summary

AccessConstructor and Description
pack-priv
ZipFileIterator(final ZipFile zipFile)

Method Summary

Modifier and TypeMethod and Description
public InputStream
public boolean
public ZipArchiveEntry
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentEntryback to summary
private ZipArchiveEntry currentEntry
nestedEnumerationback to summary
private final Enumeration<ZipArchiveEntry> nestedEnumeration
zipFileback to summary
private final ZipFile zipFile

Constructor Detail

ZipFileIteratorback to summary
pack-priv ZipFileIterator(final ZipFile zipFile)

Method Detail

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Implements org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator.getInputStream.

Annotations
@Override
hasNextback to summary
public boolean hasNext()

Implements org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator.hasNext.

Annotations
@Override
nextback to summary
public ZipArchiveEntry next()

Implements org.apache.commons.compress.changes.ChangeSetPerformer.ArchiveEntryIterator.next.

Annotations
@Override