Class Stax2Util.ByteAggregator

  • Enclosing class:
    Stax2Util

    public static final class Stax2Util.ByteAggregator
    extends java.lang.Object
    Helper class for efficiently reading and aggregating variable length byte content.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static int DEFAULT_BLOCK_ARRAY_SIZE
      Maximum block size we will use for individual non-aggregated blocks.
      private static int INITIAL_BLOCK_SIZE
      Size of the first block we will allocate.
      private int mBlockCount  
      private byte[][] mBlocks  
      private byte[] mSpareBlock
      Reusable byte buffer block; we retain biggest one from mBlocks after aggregation.
      private int mTotalLen  
      private static byte[] NO_BYTES  
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteAggregator()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] addFullBlock​(byte[] block)
      Method used to add bufferful of data to the aggregator, and get another buffer to read more data into.
      byte[] aggregateAll​(byte[] lastBlock, int lastLen)
      Method called when results are finalized and we can get the full aggregated result buffer to return to the caller
      byte[] startAggregation()
      Method called to initialize aggregation process.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_BYTES

        private static final byte[] NO_BYTES
      • INITIAL_BLOCK_SIZE

        private static final int INITIAL_BLOCK_SIZE
        Size of the first block we will allocate.
        See Also:
        Constant Field Values
      • DEFAULT_BLOCK_ARRAY_SIZE

        static final int DEFAULT_BLOCK_ARRAY_SIZE
        Maximum block size we will use for individual non-aggregated blocks. Let's limit to using 256k chunks.
        See Also:
        Constant Field Values
      • mBlocks

        private byte[][] mBlocks
      • mBlockCount

        private int mBlockCount
      • mTotalLen

        private int mTotalLen
      • mSpareBlock

        private byte[] mSpareBlock
        Reusable byte buffer block; we retain biggest one from mBlocks after aggregation.
    • Constructor Detail

      • ByteAggregator

        public ByteAggregator()
    • Method Detail

      • startAggregation

        public byte[] startAggregation()
        Method called to initialize aggregation process.
        Returns:
        Block that can be used to read in content
      • addFullBlock

        public byte[] addFullBlock​(byte[] block)
        Method used to add bufferful of data to the aggregator, and get another buffer to read more data into. Returned buffer is generally as big as or bigger than the given buffer, to try to improve performance for larger aggregations.
        Returns:
        Buffer in which to read additional data
      • aggregateAll

        public byte[] aggregateAll​(byte[] lastBlock,
                                   int lastLen)
        Method called when results are finalized and we can get the full aggregated result buffer to return to the caller