Package de.das.encrypter.processors
Class Splitter
java.lang.Object
de.das.encrypter.processors.Splitter
An instance of this class can be used to split a byte array into individual,
smaller blocks. This is necessary if large data packets (larger than 65500
bytes) are to be sent via UDP.
After creating a new instance, each call to the getNext() method returns a block of size KeyTransfer.BUFFER_SIZE, except for the last block when the total size is not an integer multiple of KeyTransfer.BUFFER_SIZE. Then a smaller byte array is returned with the remainder. When the decomposition is finished, "getNext()" returns null.
After creating a new instance, each call to the getNext() method returns a block of size KeyTransfer.BUFFER_SIZE, except for the last block when the total size is not an integer multiple of KeyTransfer.BUFFER_SIZE. Then a smaller byte array is returned with the remainder. When the decomposition is finished, "getNext()" returns null.
-
Constructor Summary
ConstructorsConstructorDescriptionSplitter(byte[] data, ProgressListener pl) Creates a new instance of the Splitter class that splits the passed byte array into individual blocks of size KeyTransfer.BUFFER_SIZE. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of already delivered blocks.byte[]getNext()Returns the next block of data to be split with size KeyTransfer.BUFFER_SIZE or smaller if it is the last block and the total size of the data to be split is not an integer multiple of KeyTransfer.BUFFER_SIZE, or null if all blocks have already been supplied.
-
Constructor Details
-
Splitter
Creates a new instance of the Splitter class that splits the passed byte array into individual blocks of size KeyTransfer.BUFFER_SIZE.- Parameters:
data- the byte array to be splitted into snaller parts.pl- a class that implements the ProgressListener interface, or null if no progress listener is needed.
-
-
Method Details
-
getBlockCount
public int getBlockCount()Returns the number of already delivered blocks.- Returns:
- the number of already delivered blocks.
-
getNext
public byte[] getNext()Returns the next block of data to be split with size KeyTransfer.BUFFER_SIZE or smaller if it is the last block and the total size of the data to be split is not an integer multiple of KeyTransfer.BUFFER_SIZE, or null if all blocks have already been supplied.- Returns:
- the next block of data or null if all blocks have already been supplied.
-