Package org.syncany.chunk
Class ZipMultiChunk
- java.lang.Object
-
- org.syncany.chunk.MultiChunk
-
- org.syncany.chunk.ZipMultiChunk
-
public class ZipMultiChunk extends MultiChunk
-
-
Field Summary
-
Fields inherited from class org.syncany.chunk.MultiChunk
id, minSize, size
-
-
Constructor Summary
Constructors Constructor Description ZipMultiChunk(java.io.File file)
ZipMultiChunk(java.io.InputStream is)
ZipMultiChunk(MultiChunkEntry.MultiChunkId id, int minSize, java.io.OutputStream os)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes a multichunk after writing/reading.java.io.InputStream
getChunkInputStream(byte[] checksum)
In read mode, this method can be used to readChunk
s in random access mode, using a chunk checksum as identifier.long
getSize()
boolean
isFull()
In write mode, this method determines the fill state of the multichunk and returns whether or not a new chunk can still be added.Chunk
read()
In read mode, this method can be used to sequentially readChunk
s from a multichunk.void
write(Chunk chunk)
In write mode, this method can be used to writeChunk
s to a multichunk.-
Methods inherited from class org.syncany.chunk.MultiChunk
equals, getId, hashCode, setId
-
-
-
-
Constructor Detail
-
ZipMultiChunk
public ZipMultiChunk(java.io.InputStream is)
-
ZipMultiChunk
public ZipMultiChunk(java.io.File file) throws java.util.zip.ZipException, java.io.IOException
- Throws:
java.util.zip.ZipException
java.io.IOException
-
ZipMultiChunk
public ZipMultiChunk(MultiChunkEntry.MultiChunkId id, int minSize, java.io.OutputStream os) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
isFull
public boolean isFull()
Description copied from class:MultiChunk
In write mode, this method determines the fill state of the multichunk and returns whether or not a new chunk can still be added. It is used by theDeduper
.- Overrides:
isFull
in classMultiChunk
- Returns:
- Returns
true
if no more chunks should be added and the chunk should be closed,false
otherwise
-
write
public void write(Chunk chunk) throws java.io.IOException
Description copied from class:MultiChunk
In write mode, this method can be used to writeChunk
s to a multichunk.Implementations must increase the
MultiChunk.size
by the amount written to the multichunk (input size sufficient) and make sure that (if required) a header is written for the first chunk.Implementations do not have to check whether or not a multichunk is full. This should be done outside the multichunker/multichunk as part of the deduplication algorithm in the
Deduper
.- Specified by:
write
in classMultiChunk
- Parameters:
chunk
- Chunk to be written to the multichunk container- Throws:
java.io.IOException
- If an exception occurs when writing to the multichunk
-
getChunkInputStream
public java.io.InputStream getChunkInputStream(byte[] checksum) throws java.io.IOException
Description copied from class:MultiChunk
In read mode, this method can be used to readChunk
s in random access mode, using a chunk checksum as identifier. The method returns a chunk input stream (the chunk's data) if the chunk is found, andnull
otherwise.If all chunks are read from a multichunk sequentially, the
MultiChunk.read()
method should be used instead.- Specified by:
getChunkInputStream
in classMultiChunk
- Parameters:
checksum
- The checksum identifying a chunk instance- Returns:
- Returns a chunk input stream (chunk data) if the chunk can be found in the multichunk, or
null
otherwise - Throws:
java.io.IOException
- If an exception occurs when reading from the multichunk
-
read
public Chunk read() throws java.io.IOException
Description copied from class:MultiChunk
In read mode, this method can be used to sequentially readChunk
s from a multichunk. The method returns a chunk until no more chunks are available, at which point it will returnnull
.If random read access on a multichunk is desired, the
getChunkInputStream()
method should be used instead.- Specified by:
read
in classMultiChunk
- Returns:
- Returns the next chunk in the opened multichunk, or
null
if no chunk is available (anymore) - Throws:
java.io.IOException
- If an exception occurs when reading from the multichunk
-
getSize
public long getSize()
- Overrides:
getSize
in classMultiChunk
-
close
public void close() throws java.io.IOException
Description copied from class:MultiChunk
Closes a multichunk after writing/reading.Implementations should close the underlying input/output stream (depending on whether the chunk was opened in read or write mode.
- Specified by:
close
in classMultiChunk
- Throws:
java.io.IOException
- If an exception occurs when closing the multichunk
-
-