org.joe_e.array
Class ByteArray.Builder

java.lang.Object
  extended by org.joe_e.array.ConstArray.Builder<E>
      extended by org.joe_e.array.ImmutableArray.Builder<E>
          extended by org.joe_e.array.PowerlessArray.Builder<Byte>
              extended by org.joe_e.array.ByteArray.Builder
All Implemented Interfaces:
ArrayBuilder<Byte>
Enclosing class:
ByteArray

public static final class ByteArray.Builder
extends PowerlessArray.Builder<Byte>

A ByteArray factory.


Method Summary
 void append(byte newByte)
          Append a byte
 void append(Byte newByte)
          Append a Byte
 void append(byte[] newBytes)
          Append an array of bytes
 void append(Byte[] newBytes)
          Append an array of Bytess
 void append(byte[] newBytes, int off, int len)
          Append a range of elements from an array of bytes
 void append(Byte[] newBytes, int off, int len)
          Append a range of elements from an array of Bytes
 ByteArray.BuilderOutputStream asOutputStream()
          Convenience method that creates an output stream using this Builder
 ByteArray snapshot()
          Create a snapshot of the current content.
 
Methods inherited from class org.joe_e.array.ConstArray.Builder
length
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

append

public void append(Byte newByte)
Append a Byte

Specified by:
append in interface ArrayBuilder<Byte>
Overrides:
append in class PowerlessArray.Builder<Byte>
Parameters:
newByte - the element to add
Throws:
IndexOutOfBoundsException - if the resulting array would exceed the maximum length of a Java array. The builder is unmodified.

append

public void append(Byte[] newBytes)
Append an array of Bytess

Specified by:
append in interface ArrayBuilder<Byte>
Overrides:
append in class PowerlessArray.Builder<Byte>
Parameters:
newBytes - the elements to add
Throws:
IndexOutOfBoundsException - if the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

append

public void append(Byte[] newBytes,
                   int off,
                   int len)
Append a range of elements from an array of Bytes

Specified by:
append in interface ArrayBuilder<Byte>
Overrides:
append in class PowerlessArray.Builder<Byte>
Parameters:
newBytes - the array to add elements from
off - the index of the first element to add
len - the number of elements to add
Throws:
IndexOutOfBoundsException - if an out-of-bounds index would be referenced or the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

snapshot

public ByteArray snapshot()
Create a snapshot of the current content.

Specified by:
snapshot in interface ArrayBuilder<Byte>
Overrides:
snapshot in class PowerlessArray.Builder<Byte>
Returns:
a ByteArray containing the elements so far

append

public void append(byte newByte)
Append a byte

Parameters:
newByte - the element to add
Throws:
IndexOutOfBoundsException - if the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

append

public void append(byte[] newBytes)
Append an array of bytes

Parameters:
newBytes - the elements to add
Throws:
IndexOutOfBoundsException - if the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

append

public void append(byte[] newBytes,
                   int off,
                   int len)
Append a range of elements from an array of bytes

Parameters:
newBytes - the array to add elements from
off - the index of the first element to add
len - the number of elements to add
Throws:
IndexOutOfBoundsException - if an out-of-bounds index would be referenced or the resulting internal array would exceed the maximum length of a Java array. The builder is unmodified.

asOutputStream

public ByteArray.BuilderOutputStream asOutputStream()
Convenience method that creates an output stream using this Builder

Returns:
a new output stream that wraps this Builder