public final class CharChunk extends AbstractChunk implements java.lang.CharSequence
Modifier and Type | Class and Description |
---|---|
static interface |
CharChunk.CharInputChannel
Input interface, used when the buffer is empty.
|
static interface |
CharChunk.CharOutputChannel
When we need more space we'll either grow the buffer ( up to the limit )
or send it to a channel.
|
ARRAY_MAX_SIZE, end, hasHashCode, isSet, start
Constructor and Description |
---|
CharChunk()
Creates a new, uninitialized CharChunk object.
|
CharChunk(int initial) |
Modifier and Type | Method and Description |
---|---|
void |
allocate(int initial,
int limit) |
void |
append(char b) |
void |
append(char[] src,
int off,
int len)
Add data to the buffer.
|
void |
append(CharChunk src) |
void |
append(java.lang.String s)
Append a string to the buffer.
|
void |
append(java.lang.String s,
int off,
int len)
Append a string to the buffer.
|
char |
charAt(int index) |
java.lang.Object |
clone() |
boolean |
endsWith(java.lang.String s) |
boolean |
equals(char[] b2,
int off2,
int len2) |
boolean |
equals(CharChunk cc) |
boolean |
equals(java.lang.Object obj) |
boolean |
equals(java.lang.String s)
Compares the message bytes to the specified String object.
|
boolean |
equalsIgnoreCase(java.lang.String s)
Compares the message bytes to the specified String object.
|
void |
flushBuffer()
Send the buffer to the sink.
|
char[] |
getBuffer() |
protected int |
getBufferElement(int index) |
char[] |
getChars() |
int |
indexOf(char c) |
static int |
indexOf(char[] chars,
int start,
int end,
char s)
Returns the first instance of the given character in the given char array
between the specified start and end.
|
int |
indexOf(char c,
int starting)
Returns the first instance of the given character in this CharChunk
starting at the specified char.
|
int |
length() |
void |
makeSpace(int count)
Make space for len chars.
|
void |
setCharInputChannel(CharChunk.CharInputChannel in)
When the buffer is empty, read the data from the input channel.
|
void |
setCharOutputChannel(CharChunk.CharOutputChannel out)
When the buffer is full, write the data to the output channel.
|
void |
setChars(char[] c,
int off,
int len)
Sets the buffer to the specified subarray of characters.
|
void |
setOptimizedWrite(boolean optimizedWrite) |
boolean |
startsWith(java.lang.String s) |
boolean |
startsWithIgnoreCase(java.lang.String s,
int pos)
Returns true if the buffer starts with the specified string.
|
java.lang.CharSequence |
subSequence(int start,
int end) |
int |
substract() |
int |
substract(char[] dest,
int off,
int len) |
java.lang.String |
toString() |
java.lang.String |
toStringInternal() |
public CharChunk()
public CharChunk(int initial)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public void allocate(int initial, int limit)
public void setOptimizedWrite(boolean optimizedWrite)
public void setChars(char[] c, int off, int len)
c
- the charactersoff
- the start offset of the characterslen
- the length of the characterspublic char[] getChars()
public char[] getBuffer()
public void setCharInputChannel(CharChunk.CharInputChannel in)
in
- The input channelpublic void setCharOutputChannel(CharChunk.CharOutputChannel out)
out
- The output channelpublic void append(char b) throws java.io.IOException
java.io.IOException
public void append(CharChunk src) throws java.io.IOException
java.io.IOException
public void append(char[] src, int off, int len) throws java.io.IOException
src
- Char arrayoff
- Offsetlen
- Lengthjava.io.IOException
- Writing overflow data to the output channel failedpublic void append(java.lang.String s) throws java.io.IOException
s
- The stringjava.io.IOException
- Writing overflow data to the output channel failedpublic void append(java.lang.String s, int off, int len) throws java.io.IOException
s
- The stringoff
- Offsetlen
- Lengthjava.io.IOException
- Writing overflow data to the output channel failedpublic int substract() throws java.io.IOException
java.io.IOException
public int substract(char[] dest, int off, int len) throws java.io.IOException
java.io.IOException
public void flushBuffer() throws java.io.IOException
java.io.IOException
- Writing overflow data to the output channel failedpublic void makeSpace(int count)
AbstractChunk.ARRAY_MAX_SIZE
.count
- The sizepublic java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public java.lang.String toStringInternal()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public boolean equals(java.lang.String s)
s
- the String to comparetrue
if the comparison succeeded, false
otherwisepublic boolean equalsIgnoreCase(java.lang.String s)
s
- the String to comparetrue
if the comparison succeeded, false
otherwisepublic boolean equals(CharChunk cc)
public boolean equals(char[] b2, int off2, int len2)
public boolean startsWith(java.lang.String s)
s
- The stringtrue
if the message bytes starts with the specified
string.public boolean startsWithIgnoreCase(java.lang.String s, int pos)
s
- the stringpos
- The positiontrue
if the start matchespublic boolean endsWith(java.lang.String s)
s
- The stringtrue
if the message bytes end with the specified
string.protected int getBufferElement(int index)
getBufferElement
in class AbstractChunk
public int indexOf(char c)
public int indexOf(char c, int starting)
c
- The characterstarting
- The start positionpublic static int indexOf(char[] chars, int start, int end, char s)
chars
- The array to searchstart
- The point to start searching from in the arrayend
- The point to stop searching in the arrays
- The character to search forpublic char charAt(int index)
charAt
in interface java.lang.CharSequence
public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
public int length()
length
in interface java.lang.CharSequence
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.