akka.util
Class ByteStringBuilder

java.lang.Object
  extended by akka.util.ByteStringBuilder
All Implemented Interfaces:
scala.collection.generic.Clearable, scala.collection.generic.Growable<java.lang.Object>, scala.collection.mutable.Builder<java.lang.Object,ByteString>

public final class ByteStringBuilder
extends java.lang.Object
implements scala.collection.mutable.Builder<java.lang.Object,ByteString>

A mutable builder for efficiently creating a ByteString.

The created ByteString is not automatically compacted.


Constructor Summary
ByteStringBuilder()
           
 
Method Summary
 ByteStringBuilder append(ByteString bs)
          Java API: append a ByteString to this builder.
 java.io.OutputStream asOutputStream()
          Directly wraps this ByteStringBuilder in an OutputStream.
 void clear()
           
protected  ByteStringBuilder fillArray(int len, scala.Function2<byte[],java.lang.Object,scala.runtime.BoxedUnit> fill)
           
protected  ByteStringBuilder fillByteBuffer(int len, java.nio.ByteOrder byteOrder, scala.Function1<java.nio.ByteBuffer,scala.runtime.BoxedUnit> fill)
           
 int length()
           
 ByteStringBuilder putByte(byte x)
          Add a single Byte to this builder.
 ByteStringBuilder putByteArrayUnsafe(byte[] xs)
           
 ByteStringBuilder putBytes(byte[] array)
          Add a number of Bytes from an array to this builder.
 ByteStringBuilder putBytes(byte[] array, int start, int len)
          Add a number of Bytes from an array to this builder.
 ByteStringBuilder putDouble(double x, java.nio.ByteOrder byteOrder)
          Add a single Double to this builder.
 ByteStringBuilder putDoubles(double[] array, java.nio.ByteOrder byteOrder)
          Add a number of Doubles from an array to this builder.
 ByteStringBuilder putDoubles(double[] array, int start, int len, java.nio.ByteOrder byteOrder)
          Add a number of Doubles from an array to this builder.
 ByteStringBuilder putFloat(float x, java.nio.ByteOrder byteOrder)
          Add a single Float to this builder.
 ByteStringBuilder putFloats(float[] array, java.nio.ByteOrder byteOrder)
          Add a number of Floats from an array to this builder.
 ByteStringBuilder putFloats(float[] array, int start, int len, java.nio.ByteOrder byteOrder)
          Add a number of Floats from an array to this builder.
 ByteStringBuilder putInt(int x, java.nio.ByteOrder byteOrder)
          Add a single Int to this builder.
 ByteStringBuilder putInts(int[] array, java.nio.ByteOrder byteOrder)
          Add a number of Ints from an array to this builder.
 ByteStringBuilder putInts(int[] array, int start, int len, java.nio.ByteOrder byteOrder)
          Add a number of Ints from an array to this builder.
 ByteStringBuilder putLong(long x, java.nio.ByteOrder byteOrder)
          Add a single Long to this builder.
 ByteStringBuilder putLongPart(long x, int n, java.nio.ByteOrder byteOrder)
          Add the n least significant bytes of the given Long to this builder.
 ByteStringBuilder putLongs(long[] array, java.nio.ByteOrder byteOrder)
          Add a number of Longs from an array to this builder.
 ByteStringBuilder putLongs(long[] array, int start, int len, java.nio.ByteOrder byteOrder)
          Add a number of Longs from an array to this builder.
 ByteStringBuilder putShort(int x, java.nio.ByteOrder byteOrder)
          Add a single Short to this builder.
 ByteStringBuilder putShorts(short[] array, java.nio.ByteOrder byteOrder)
          Add a number of Shorts from an array to this builder.
 ByteStringBuilder putShorts(short[] array, int start, int len, java.nio.ByteOrder byteOrder)
          Add a number of Shorts from an array to this builder.
 ByteString result()
           
 void sizeHint(int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface scala.collection.mutable.Builder
$plus$eq, mapResult, sizeHint, sizeHint, sizeHintBounded
 
Methods inherited from interface scala.collection.generic.Growable
$plus$eq, $plus$plus$eq
 

Constructor Detail

ByteStringBuilder

public ByteStringBuilder()
Method Detail

fillArray

protected ByteStringBuilder fillArray(int len,
                                      scala.Function2<byte[],java.lang.Object,scala.runtime.BoxedUnit> fill)

fillByteBuffer

protected final ByteStringBuilder fillByteBuffer(int len,
                                                 java.nio.ByteOrder byteOrder,
                                                 scala.Function1<java.nio.ByteBuffer,scala.runtime.BoxedUnit> fill)

length

public int length()

sizeHint

public void sizeHint(int len)
Specified by:
sizeHint in interface scala.collection.mutable.Builder<java.lang.Object,ByteString>

putByteArrayUnsafe

public ByteStringBuilder putByteArrayUnsafe(byte[] xs)

append

public ByteStringBuilder append(ByteString bs)
Java API: append a ByteString to this builder.

Parameters:
bs - (undocumented)
Returns:
(undocumented)

putByte

public ByteStringBuilder putByte(byte x)
Add a single Byte to this builder.

Parameters:
x - (undocumented)
Returns:
(undocumented)

putShort

public ByteStringBuilder putShort(int x,
                                  java.nio.ByteOrder byteOrder)
Add a single Short to this builder.

Parameters:
x - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putInt

public ByteStringBuilder putInt(int x,
                                java.nio.ByteOrder byteOrder)
Add a single Int to this builder.

Parameters:
x - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putLong

public ByteStringBuilder putLong(long x,
                                 java.nio.ByteOrder byteOrder)
Add a single Long to this builder.

Parameters:
x - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putLongPart

public ByteStringBuilder putLongPart(long x,
                                     int n,
                                     java.nio.ByteOrder byteOrder)
Add the n least significant bytes of the given Long to this builder.

Parameters:
x - (undocumented)
n - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putFloat

public ByteStringBuilder putFloat(float x,
                                  java.nio.ByteOrder byteOrder)
Add a single Float to this builder.

Parameters:
x - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putDouble

public ByteStringBuilder putDouble(double x,
                                   java.nio.ByteOrder byteOrder)
Add a single Double to this builder.

Parameters:
x - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putBytes

public ByteStringBuilder putBytes(byte[] array)
Add a number of Bytes from an array to this builder.

Parameters:
array - (undocumented)
Returns:
(undocumented)

putBytes

public ByteStringBuilder putBytes(byte[] array,
                                  int start,
                                  int len)
Add a number of Bytes from an array to this builder.

Parameters:
array - (undocumented)
start - (undocumented)
len - (undocumented)
Returns:
(undocumented)

putShorts

public ByteStringBuilder putShorts(short[] array,
                                   java.nio.ByteOrder byteOrder)
Add a number of Shorts from an array to this builder.

Parameters:
array - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putShorts

public ByteStringBuilder putShorts(short[] array,
                                   int start,
                                   int len,
                                   java.nio.ByteOrder byteOrder)
Add a number of Shorts from an array to this builder.

Parameters:
array - (undocumented)
start - (undocumented)
len - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putInts

public ByteStringBuilder putInts(int[] array,
                                 java.nio.ByteOrder byteOrder)
Add a number of Ints from an array to this builder.

Parameters:
array - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putInts

public ByteStringBuilder putInts(int[] array,
                                 int start,
                                 int len,
                                 java.nio.ByteOrder byteOrder)
Add a number of Ints from an array to this builder.

Parameters:
array - (undocumented)
start - (undocumented)
len - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putLongs

public ByteStringBuilder putLongs(long[] array,
                                  java.nio.ByteOrder byteOrder)
Add a number of Longs from an array to this builder.

Parameters:
array - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putLongs

public ByteStringBuilder putLongs(long[] array,
                                  int start,
                                  int len,
                                  java.nio.ByteOrder byteOrder)
Add a number of Longs from an array to this builder.

Parameters:
array - (undocumented)
start - (undocumented)
len - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putFloats

public ByteStringBuilder putFloats(float[] array,
                                   java.nio.ByteOrder byteOrder)
Add a number of Floats from an array to this builder.

Parameters:
array - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putFloats

public ByteStringBuilder putFloats(float[] array,
                                   int start,
                                   int len,
                                   java.nio.ByteOrder byteOrder)
Add a number of Floats from an array to this builder.

Parameters:
array - (undocumented)
start - (undocumented)
len - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putDoubles

public ByteStringBuilder putDoubles(double[] array,
                                    java.nio.ByteOrder byteOrder)
Add a number of Doubles from an array to this builder.

Parameters:
array - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

putDoubles

public ByteStringBuilder putDoubles(double[] array,
                                    int start,
                                    int len,
                                    java.nio.ByteOrder byteOrder)
Add a number of Doubles from an array to this builder.

Parameters:
array - (undocumented)
start - (undocumented)
len - (undocumented)
byteOrder - (undocumented)
Returns:
(undocumented)

clear

public void clear()
Specified by:
clear in interface scala.collection.generic.Clearable
Specified by:
clear in interface scala.collection.generic.Growable<java.lang.Object>
Specified by:
clear in interface scala.collection.mutable.Builder<java.lang.Object,ByteString>

result

public ByteString result()
Specified by:
result in interface scala.collection.mutable.Builder<java.lang.Object,ByteString>

asOutputStream

public java.io.OutputStream asOutputStream()
Directly wraps this ByteStringBuilder in an OutputStream. Write operations on the stream are forwarded to the builder.

Returns:
(undocumented)