Class ChangeSetPerformer<I extends ArchiveInputStream<E>,O extends ArchiveOutputStream<E>,E extends ArchiveEntry>
- java.lang.Object
-
- org.apache.commons.compress.changes.ChangeSetPerformer<I,O,E>
-
- Type Parameters:
I
- TheArchiveInputStream
type.O
- TheArchiveOutputStream
type.E
- TheArchiveEntry
type, must be compatible between the inputI
and outputO
stream types.
public class ChangeSetPerformer<I extends ArchiveInputStream<E>,O extends ArchiveOutputStream<E>,E extends ArchiveEntry> extends java.lang.Object
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 Class Summary
Nested Classes Modifier and Type Class Description private static interface
ChangeSetPerformer.ArchiveEntryIterator<E extends ArchiveEntry>
Abstracts getting entries and streams for archive entries.private static class
ChangeSetPerformer.ArchiveInputStreamIterator<E extends ArchiveEntry>
private static class
ChangeSetPerformer.ZipFileIterator
-
Constructor Summary
Constructors Constructor Description ChangeSetPerformer(ChangeSet<E> changeSet)
Constructs a ChangeSetPerformer with the changes from this ChangeSet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
copyStream(java.io.InputStream inputStream, O outputStream, E archiveEntry)
Copies the ArchiveEntry to the Output streamprivate boolean
isDeletedLater(java.util.Set<Change<E>> workingSet, E entry)
Checks if an ArchiveEntry is deleted later in the ChangeSet.ChangeSetResults
perform(I inputStream, O outputStream)
Performs all changes collected in this ChangeSet on the input stream and streams the result to the output stream.ChangeSetResults
perform(ZipFile zipFile, O outputStream)
Performs all changes collected in this ChangeSet on the ZipFile and streams the result to the output stream.private ChangeSetResults
perform(ChangeSetPerformer.ArchiveEntryIterator<E> entryIterator, O outputStream)
Performs all changes collected in this ChangeSet on the input entries and streams the result to the output stream.
-
-
-
Field Detail
-
changes
private final java.util.Set<Change<E extends ArchiveEntry>> changes
-
-
Method Detail
-
copyStream
private void copyStream(java.io.InputStream inputStream, O outputStream, E archiveEntry) throws java.io.IOException
Copies the ArchiveEntry to the Output stream- Parameters:
inputStream
- the stream to read the data fromoutputStream
- the stream to write the data toarchiveEntry
- the entry to write- Throws:
java.io.IOException
- if data cannot be read or written
-
isDeletedLater
private boolean isDeletedLater(java.util.Set<Change<E>> workingSet, 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
- the entry to check- Returns:
- true, if this entry has a deletion change later, false otherwise
-
perform
private ChangeSetResults perform(ChangeSetPerformer.ArchiveEntryIterator<E> entryIterator, O outputStream) throws java.io.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
- the entries to perform the changes onoutputStream
- the resulting OutputStream with all modifications- Returns:
- the results of this operation
- Throws:
java.io.IOException
- if a read/write error occurs
-
perform
public ChangeSetResults perform(I inputStream, O outputStream) throws java.io.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
- the InputStream to perform the changes onoutputStream
- the resulting OutputStream with all modifications- Returns:
- the results of this operation
- Throws:
java.io.IOException
- if a read/write error occurs
-
perform
public ChangeSetResults perform(ZipFile zipFile, O outputStream) throws java.io.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
- the ZipFile to perform the changes onoutputStream
- the resulting OutputStream with all modifications- Returns:
- the results of this operation
- Throws:
java.io.IOException
- if a read/write error occurs- Since:
- 1.5
-
-