Package jebl.evolution.io
Class ByteBuilder
java.lang.Object
jebl.evolution.io.ByteBuilder
- All Implemented Interfaces:
Appendable,CharSequence
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
ConstructorsConstructorDescriptionByteBuilder(int maxCapacity) Constructs a ByteBuilder that will never grow beyondmaxCapacitybytes in length. -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) Appends an ASCII character (seeisCharacterAscii(char)) to this ByteBuilder.append(CharSequence charSequence) Appends an ASCII CharSequence to this ByteBuilder.append(CharSequence csq, int start, int end) charcharAt(int index) static booleanisCharacterAscii(char c) intlength()subSequence(int start, int end) toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
ByteBuilder
public ByteBuilder(int maxCapacity) Constructs a ByteBuilder that will never grow beyondmaxCapacitybytes 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
Appends an ASCII character (seeisCharacterAscii(char)) to this ByteBuilder.- Specified by:
appendin interfaceAppendable- Parameters:
c- ASCII character to append- Returns:
- this ByteBuilder
- Throws:
IllegalArgumentException- if c is not an ASCII character
-
append
Appends an ASCII CharSequence to this ByteBuilder.- Specified by:
appendin interfaceAppendable- Parameters:
charSequence- ASCII CharSequence to append- Returns:
- this ByteBuilder
- Throws:
IllegalArgumentException- if charSequence contains non-ASCII charactersIOException
-
append
- Specified by:
appendin interfaceAppendable- Throws:
IOException
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-