Klasse CharArrayBuffer
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.util.CharArrayBuffer
The
CharArrayBuffer is intended as a lightweight partial implementation
of the StringBuffer class, but using char[]'s instead of Strings.
The CharArrayBuffer maintains a list of char[]'s
which don't get appended until the user asks for them. The following
code illustrates how to use the class.
CharArrayBuffer buffer = new CharArrayBuffer(myCharArray);
buffer.append(moreBytes, 0, someLength);
myCharArray = buffer.getContents();
NOTE: This class is not Thread safe!
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected char[][]This is the buffer of char arrays which must be appended together during the getContents method.static final intThe default buffer size.protected intThe end of the bufferprotected int[][]A buffer of ranges which is maintained along with the buffer.protected intThe current size of the buffer. -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungCreates aCharArrayBufferwith the default buffer size (10).CharArrayBuffer(char[] first) Creates aCharArrayBufferwith the default buffer size, and sets the first element in the buffer to be the given char[].CharArrayBuffer(char[] first, int size) Creates aCharArrayBufferwith the given buffer size, and sets the first element in the buffer to be the given char array.CharArrayBuffer(int size) Creates aCharArrayBufferwith the given buffer size. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungappend(char c) Appends the given char.append(char[] src) Appends the entire given char array.append(char[] src, int start, int length) Appends a sub array of the given array to the buffer.Appends the given String to the buffer.char[]Returns the entire contents of the buffer as one char[] or null if nothing has been put in the buffer.toString()Returns the contents of the buffer as a String, or an empty string if the buffer is empty.
-
Felddetails
-
buffer
protected char[][] bufferThis is the buffer of char arrays which must be appended together during the getContents method. -
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEThe default buffer size.- Siehe auch:
-
end
protected int endThe end of the buffer -
size
protected int sizeThe current size of the buffer. -
ranges
protected int[][] rangesA buffer of ranges which is maintained along with the buffer. Ranges are of the form {start, length}. Enables append(char[] array, int start, int end).
-
-
Konstruktordetails
-
CharArrayBuffer
public CharArrayBuffer()Creates aCharArrayBufferwith the default buffer size (10). -
CharArrayBuffer
public CharArrayBuffer(char[] first) Creates aCharArrayBufferwith the default buffer size, and sets the first element in the buffer to be the given char[].- Parameter:
first- - the first element to be placed in the buffer, ignored if null
-
CharArrayBuffer
public CharArrayBuffer(char[] first, int size) Creates aCharArrayBufferwith the given buffer size, and sets the first element in the buffer to be the given char array.- Parameter:
first- - the first element of the buffer, ignored if null.size- - the buffer size, if less than 1, set to the DEFAULT_BUFFER_SIZE.
-
CharArrayBuffer
public CharArrayBuffer(int size) Creates aCharArrayBufferwith the given buffer size.- Parameter:
size- - the size of the buffer.
-
-
Methodendetails
-
append
Appends the entire given char array. Given for convenience.- Parameter:
src- - a char array which is appended to the end of the buffer.
-
append
Appends a sub array of the given array to the buffer.- Parameter:
src- - the next array of characters to be appended to the buffer, ignored if nullstart- - the start index in the src array.length- - the number of characters from start to be appended- Löst aus:
ArrayIndexOutOfBoundsException- - if arguments specify an array index out of bounds.
-
append
Appends the given char. Given for convenience.- Parameter:
c- - a char which is appended to the end of the buffer.
-
append
Appends the given String to the buffer. Given for convenience, use #append(char[]) if possible- Parameter:
src- - a char array which is appended to the end of the buffer.
-
getContents
public char[] getContents()Returns the entire contents of the buffer as one char[] or null if nothing has been put in the buffer. -
toString
Returns the contents of the buffer as a String, or an empty string if the buffer is empty.
-