Package jebl.evolution.io
Class ByteBuilder
- java.lang.Object
-
- jebl.evolution.io.ByteBuilder
-
- All Implemented Interfaces:
java.lang.Appendable,java.lang.CharSequence
public class ByteBuilder extends java.lang.Object implements java.lang.CharSequence, java.lang.AppendableSimilar 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 beyondmaxCapacitybytes in length.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBuilderappend(char c)Appends an ASCII character (seeisCharacterAscii(char)) to this ByteBuilder.ByteBuilderappend(java.lang.CharSequence charSequence)Appends an ASCII CharSequence to this ByteBuilder.ByteBuilderappend(java.lang.CharSequence csq, int start, int end)charcharAt(int index)static booleanisCharacterAscii(char c)intlength()java.lang.CharSequencesubSequence(int start, int end)java.lang.StringtoString()
-
-
-
Constructor Detail
-
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 Detail
-
isCharacterAscii
public static boolean isCharacterAscii(char c)
-
append
public ByteBuilder append(char c)
Appends an ASCII character (seeisCharacterAscii(char)) to this ByteBuilder.- Specified by:
appendin interfacejava.lang.Appendable- Parameters:
c- ASCII character to append- Returns:
- this ByteBuilder
- Throws:
java.lang.IllegalArgumentException- if c is not an ASCII character
-
append
public ByteBuilder append(java.lang.CharSequence charSequence) throws java.io.IOException
Appends an ASCII CharSequence to this ByteBuilder.- Specified by:
appendin interfacejava.lang.Appendable- Parameters:
charSequence- ASCII CharSequence to append- Returns:
- this ByteBuilder
- Throws:
java.lang.IllegalArgumentException- if charSequence contains non-ASCII charactersjava.io.IOException
-
append
public ByteBuilder append(java.lang.CharSequence csq, int start, int end) throws java.io.IOException
- Specified by:
appendin interfacejava.lang.Appendable- Throws:
java.io.IOException
-
length
public int length()
- Specified by:
lengthin interfacejava.lang.CharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfacejava.lang.CharSequence
-
subSequence
public java.lang.CharSequence subSequence(int start, int end)- Specified by:
subSequencein interfacejava.lang.CharSequence
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfacejava.lang.CharSequence- Overrides:
toStringin classjava.lang.Object
-
-