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 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 prefix.
    `protected int` | `_segmentBytes`
    `protected int` | `_typedTag`

  - ### Constructor Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `append(byte[] buf, int offset, int len)`
    `ByteAccumulator` | `finish(OutputStream out)`
    `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 prefix.

    - #### _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

  - ### Constructor Detail

    - #### ByteAccumulator

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

    - #### ByteAccumulator

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

  - ### 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)
                                 throws IOException

      Throws:
        `IOException`

Copyright © 2016 FasterXML. All rights reserved.