com.fasterxml.jackson.dataformat.protobuf

## Class ByteAccumulator

- java.lang.Object
- - com.fasterxml.jackson.dataformat.protobuf.ByteAccumulator

-     public class ByteAccumulator
      extends Object

  Helper object used for buffering content for cases where we need (byte-)length prefixes for content like packed arrays, embedded messages, Strings and (perhaps) binary content.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected com.fasterxml.jackson.dataformat.protobuf.ByteAccumulator.Segment` | `_firstSegment`
    `protected com.fasterxml.jackson.dataformat.protobuf.ByteAccumulator.Segment` | `_lastSegment`
    `protected ByteAccumulator` | `_parent`
    `protected int` | `_parentStart` Pointer to start of contents provided by parent, preceding room for prefix (that is, same as or less than `_prefixOffset`)
    `protected byte[]` | `_prefixBuffer` Caller-provided buffer in which optional type prefix, and mandatory length indicator may be added.
    `protected int` | `_prefixOffset` Offset within `_prefixBuffer` where there is room for encoding prefix (type, tag, length).
    `protected int` | `_segmentBytes` Total number of bytes contained within buffers, to be used for length prefix.
    `protected int` | `_typedTag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ByteAccumulator(ByteAccumulator p, int typedTag, byte[] prefixBuffer, int prefixOffset, int parentStart)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `append(byte[] buf, int offset, int len)`
    `ByteAccumulator` | `finish(OutputStream out, byte[] input)`
    `ByteAccumulator` | `finish(OutputStream out, byte[] input, int offset, int len)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _parent

          protected final ByteAccumulator _parent

    - #### _prefixBuffer

          protected final byte[] _prefixBuffer

      Caller-provided buffer in which optional type prefix, and mandatory length indicator may be added. Caller ensures there is enough room for both, i.e. up to 10 bytes (if both) or 5 bytes (if just length)

    - #### _prefixOffset

          protected final int _prefixOffset

      Offset within `_prefixBuffer` where there is room for encoding prefix (type, tag, length).

    - #### _typedTag

          protected final int _typedTag

    - #### _firstSegment

          protected com.fasterxml.jackson.dataformat.protobuf.ByteAccumulator.Segment _firstSegment

    - #### _lastSegment

          protected com.fasterxml.jackson.dataformat.protobuf.ByteAccumulator.Segment _lastSegment

    - #### _segmentBytes

          protected int _segmentBytes

      Total number of bytes contained within buffers, to be used for length prefix.

    - #### _parentStart

          protected int _parentStart

      Pointer to start of contents provided by parent, preceding room for prefix (that is, same as or less than `_prefixOffset`)
      Since:
        2.8.8

  - ### Constructor Detail

    - #### ByteAccumulator

          public ByteAccumulator(ByteAccumulator p,
                         int typedTag,
                         byte[] prefixBuffer,
                         int prefixOffset,
                         int parentStart)

  - ### Method Detail

    - #### append

          public void append(byte[] buf,
                    int offset,
                    int len)

    - #### finish

          public ByteAccumulator finish(OutputStream out,
                               byte[] input,
                               int offset,
                               int len)
                                 throws IOException

      Throws:
        `IOException`

    - #### finish

          public ByteAccumulator finish(OutputStream out,
                               byte[] input)
                                 throws IOException

      Throws:
        `IOException`

Copyright © 2017 FasterXML. All rights reserved.