Class Splitter

java.lang.Object
de.das.encrypter.processors.Splitter

public class Splitter extends Object
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.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Splitter(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 Type
    Method
    Description
    int
    Returns the number of already delivered blocks.
    byte[]
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Splitter

      public Splitter(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.
      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.