Package jebl.evolution.io

# Class ByteBuilder

java.lang.Object
jebl.evolution.io.ByteBuilder

All Implemented Interfaces:
  `Appendable`, `CharSequence`

public class ByteBuilder extends Object implements CharSequence, Appendable
Similar to a StringBuilder, but its internal buffer is a byte[] with one entry for each character, so it can only correctly append single-byte characters.

Version:
  $Id: ByteBuilder.java 879 2008-01-31 04:23:43Z twobeers $
Author:
  Joseph Heled

## Constructor Summary

Constructors
Constructor
Description
`ByteBuilder(int maxCapacity)`
Constructs a ByteBuilder that will never grow beyond `maxCapacity` bytes in length.

## Method Summary

Modifier and Type
Method
Description
`ByteBuilder`
`append(char c)`
Appends an ASCII character (see `isCharacterAscii(char)`) to this ByteBuilder.
`ByteBuilder`
`append(CharSequence charSequence)`
Appends an ASCII CharSequence to this ByteBuilder.
`ByteBuilder`
`append(CharSequence csq, int start, int end)`
`char`
`charAt(int index)`
`static boolean`
`isCharacterAscii(char c)`
`int`
`length()`
`CharSequence`
`subSequence(int start, int end)`
`String`
`toString()`

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

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.lang.CharSequence

`chars, codePoints, isEmpty`

## Constructor Details

### ByteBuilder

public ByteBuilder(int maxCapacity)
Constructs a ByteBuilder that will never grow beyond `maxCapacity` bytes in length. If you don't want to limit the size this ByteBuilder can grow to, you should pass in Integer.MAX_VALUE here

Parameters:
  `maxCapacity` - The maximum, NOT the initial capacity of this ByteBuilder

## Method Details

### isCharacterAscii

public static boolean isCharacterAscii(char c)

### append

public ByteBuilder append(char c)
Appends an ASCII character (see `isCharacterAscii(char)`) to this ByteBuilder.

Specified by:
  `append` in interface `Appendable`
Parameters:
  `c` - ASCII character to append
Returns:
  this ByteBuilder
Throws:
  `IllegalArgumentException` - if c is not an ASCII character

### append

public ByteBuilder append(CharSequence charSequence) throws IOException
Appends an ASCII CharSequence to this ByteBuilder.

Specified by:
  `append` in interface `Appendable`
Parameters:
  `charSequence` - ASCII CharSequence to append
Returns:
  this ByteBuilder
Throws:
  `IllegalArgumentException` - if charSequence contains non-ASCII characters
  `IOException`

### append

public ByteBuilder append(CharSequence csq, int start, int end) throws IOException

Specified by:
  `append` in interface `Appendable`
Throws:
  `IOException`

### length

public int length()

Specified by:
  `length` in interface `CharSequence`

### charAt

public char charAt(int index)

Specified by:
  `charAt` in interface `CharSequence`

### subSequence

public CharSequence subSequence(int start, int end)

Specified by:
  `subSequence` in interface `CharSequence`

### toString

public String toString()

Specified by:
  `toString` in interface `CharSequence`
Overrides:
  `toString` in class `Object`