Class ChangeSetPerformer
- java.lang.Object
-
- org.apache.commons.compress.changes.ChangeSetPerformer
-
public class ChangeSetPerformer extends java.lang.ObjectPerforms 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 (package private) static interfaceChangeSetPerformer.ArchiveEntryIteratorUsed in perform to abstract out getting entries and streams for those entries.private static classChangeSetPerformer.ArchiveInputStreamIteratorprivate static classChangeSetPerformer.ZipFileIterator
-
Constructor Summary
Constructors Constructor Description ChangeSetPerformer(ChangeSet changeSet)Constructs a ChangeSetPerformer with the changes from this ChangeSet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcopyStream(java.io.InputStream in, ArchiveOutputStream out, ArchiveEntry entry)Copies the ArchiveEntry to the Output streamprivate booleanisDeletedLater(java.util.Set<Change> workingSet, ArchiveEntry entry)Checks if an ArchiveEntry is deleted later in the ChangeSet.ChangeSetResultsperform(ArchiveInputStream in, ArchiveOutputStream out)Performs all changes collected in this ChangeSet on the input stream and streams the result to the output stream.ChangeSetResultsperform(ZipFile in, ArchiveOutputStream out)Performs all changes collected in this ChangeSet on the ZipFile and streams the result to the output stream.private ChangeSetResultsperform(ChangeSetPerformer.ArchiveEntryIterator entryIterator, ArchiveOutputStream out)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> changes
-
-
Constructor Detail
-
ChangeSetPerformer
public ChangeSetPerformer(ChangeSet changeSet)
Constructs a ChangeSetPerformer with the changes from this ChangeSet- Parameters:
changeSet- the ChangeSet which operations are used for performing
-
-
Method Detail
-
perform
public ChangeSetResults perform(ArchiveInputStream in, ArchiveOutputStream out) 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:
in- the InputStream to perform the changes onout- the resulting OutputStream with all modifications- Returns:
- the results of this operation
- Throws:
java.io.IOException- if an read/write error occurs
-
perform
public ChangeSetResults perform(ZipFile in, ArchiveOutputStream out) 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:
in- the ZipFile to perform the changes onout- the resulting OutputStream with all modifications- Returns:
- the results of this operation
- Throws:
java.io.IOException- if an read/write error occurs- Since:
- 1.5
-
perform
private ChangeSetResults perform(ChangeSetPerformer.ArchiveEntryIterator entryIterator, ArchiveOutputStream out) 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 onout- the resulting OutputStream with all modifications- Returns:
- the results of this operation
- Throws:
java.io.IOException- if an read/write error occurs
-
isDeletedLater
private boolean isDeletedLater(java.util.Set<Change> workingSet, ArchiveEntry entry)
Checks if an ArchiveEntry is deleted later in the ChangeSet. This is necessary if an 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 an deletion change later, false otherwise
-
copyStream
private void copyStream(java.io.InputStream in, ArchiveOutputStream out, ArchiveEntry entry) throws java.io.IOExceptionCopies the ArchiveEntry to the Output stream- Parameters:
in- the stream to read the data fromout- the stream to write the data toentry- the entry to write- Throws:
java.io.IOException- if data cannot be read or written
-
-