|
|||||||||
| Home >> All >> java >> [ nio overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.nio
Class CharBuffer

java.lang.Objectjava.nio.Buffer
java.nio.CharBuffer
- All Implemented Interfaces:
- java.lang.CharSequence, java.lang.Comparable
- Direct Known Subclasses:
- CharBufferImpl, CharViewBufferImpl
- public abstract class CharBuffer
- extends Buffer
- implements java.lang.Comparable, java.lang.CharSequence
- extends Buffer
- Since:
- 1.4
| Field Summary | |
(package private) int |
array_offset
|
(package private) char[] |
backing_buffer
|
| Fields inherited from class java.nio.Buffer |
address, cap, limit, mark, pos |
| Constructor Summary | |
(package private) |
CharBuffer(int capacity,
int limit,
int position,
int mark)
|
| Method Summary | |
static CharBuffer |
allocate(int capacity)
Allocates a new CharBuffer object with a given capacity. |
char[] |
array()
Returns the char array that backs this buffer. |
int |
arrayOffset()
Returns the offset within this buffer's backing array of the first element. |
abstract CharBuffer |
asReadOnlyBuffer()
Creates a new read-only CharBuffer that shares this
buffer's content. |
char |
charAt(int index)
Returns the character at position() + index. |
abstract CharBuffer |
compact()
Compacts this buffer. |
int |
compareTo(java.lang.Object obj)
Compares two CharBuffer objects. |
abstract CharBuffer |
duplicate()
Creates a new CharBuffer that shares this buffer's
content. |
boolean |
equals(java.lang.Object obj)
Checks if this buffer is equal to obj. |
abstract char |
get()
Reads the char at this buffer's current position,
and then increments the position. |
CharBuffer |
get(char[] dst)
This method transfers chars from this buffer into the given
destination array. |
CharBuffer |
get(char[] dst,
int offset,
int length)
This method transfers chars from this buffer into the given
destination array. |
abstract char |
get(int index)
Absolute get method. |
boolean |
hasArray()
Tells whether ot not this buffer is backed by an accessible char array. |
int |
hashCode()
Calculates a hash code for this buffer. |
abstract boolean |
isDirect()
Tells wether or not this buffer is direct. |
int |
length()
Returns the length of the remaining chars in this buffer. |
abstract ByteOrder |
order()
Returns the byte order of this buffer. |
abstract CharBuffer |
put(char b)
Writes the char at this buffer's current position,
and then increments the position. |
CharBuffer |
put(char[] src)
Writes the content of the the char array src
into the buffer. |
CharBuffer |
put(char[] src,
int offset,
int length)
Writes the content of the the char array src
into the buffer. |
CharBuffer |
put(CharBuffer src)
Writes the content of the the CharBUFFER src
into the buffer. |
abstract CharBuffer |
put(int index,
char b)
Absolute put method. |
CharBuffer |
put(java.lang.String str)
Relative put method. |
CharBuffer |
put(java.lang.String str,
int start,
int length)
Relative put method. |
abstract CharBuffer |
slice()
Creates a new CharBuffer whose content is a shared
subsequence of this buffer's content. |
abstract java.lang.CharSequence |
subSequence(int start,
int length)
Creates a new character buffer that represents the specified subsequence of this buffer, relative to the current position. |
java.lang.String |
toString()
Returns the remaining content of the buffer as a string. |
static CharBuffer |
wrap(char[] array)
Wraps a char array into a CharBuffer
object. |
static CharBuffer |
wrap(char[] array,
int offset,
int length)
Wraps a char array into a CharBuffer
object. |
static CharBuffer |
wrap(java.lang.CharSequence seq)
Wraps a character sequence into a CharBuffer object. |
static CharBuffer |
wrap(java.lang.CharSequence seq,
int start,
int end)
Wraps a character sequence into a CharBuffer object. |
| Methods inherited from class java.nio.Buffer |
capacity, checkArraySize, checkForOverflow, checkForOverflow, checkForUnderflow, checkForUnderflow, checkIfReadOnly, checkIndex, clear, flip, hasRemaining, isReadOnly, limit, limit, mark, position, position, remaining, reset, rewind |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
array_offset
int array_offset
backing_buffer
char[] backing_buffer
| Constructor Detail |
CharBuffer
CharBuffer(int capacity,
int limit,
int position,
int mark)
| Method Detail |
allocate
public static CharBuffer allocate(int capacity)
- Allocates a new
CharBufferobject with a given capacity.
wrap
public static final CharBuffer wrap(char[] array, int offset, int length)
- Wraps a
chararray into aCharBufferobject.
wrap
public static final CharBuffer wrap(java.lang.CharSequence seq)
- Wraps a character sequence into a
CharBufferobject.
wrap
public static final CharBuffer wrap(java.lang.CharSequence seq, int start, int end)
- Wraps a character sequence into a
CharBufferobject.
wrap
public static final CharBuffer wrap(char[] array)
- Wraps a
chararray into aCharBufferobject.
get
public CharBuffer get(char[] dst, int offset, int length)
- This method transfers
chars from this buffer into the given destination array. Before the transfer, it checks if there are fewer than lengthchars remaining in this buffer.
get
public CharBuffer get(char[] dst)
- This method transfers
chars from this buffer into the given destination array.
put
public CharBuffer put(CharBuffer src)
- Writes the content of the the
CharBUFFERsrc into the buffer. Before the transfer, it checks if there is fewer thansrc.remaining()space remaining in this buffer.
put
public CharBuffer put(char[] src, int offset, int length)
- Writes the content of the the
char arraysrc into the buffer. Before the transfer, it checks if there is fewer than length space remaining in this buffer.
put
public final CharBuffer put(char[] src)
- Writes the content of the the
char arraysrc into the buffer.
hasArray
public final boolean hasArray()
- Tells whether ot not this buffer is backed by an accessible
chararray.
array
public final char[] array()
- Returns the
chararray that backs this buffer.
arrayOffset
public final int arrayOffset()
- Returns the offset within this buffer's backing array of the first element.
hashCode
public int hashCode()
- Calculates a hash code for this buffer.
This is done with int arithmetic,
where ** represents exponentiation, by this formula:
s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... + (s[limit()-1]+30)*31**(limit()-1). Where s is the buffer data. Note that the hashcode is dependent on buffer content, and therefore is not useful if the buffer content may change.
equals
public boolean equals(java.lang.Object obj)
- Checks if this buffer is equal to obj.
compareTo
public int compareTo(java.lang.Object obj)
- Compares two
CharBufferobjects.- Specified by:
compareToin interfacejava.lang.Comparable
order
public abstract ByteOrder order()
- Returns the byte order of this buffer.
get
public abstract char get()
- Reads the
charat this buffer's current position, and then increments the position.
put
public abstract CharBuffer put(char b)
- Writes the
charat this buffer's current position, and then increments the position.
get
public abstract char get(int index)
- Absolute get method.
put
public abstract CharBuffer put(int index, char b)
- Absolute put method.
compact
public abstract CharBuffer compact()
- Compacts this buffer.
isDirect
public abstract boolean isDirect()
- Tells wether or not this buffer is direct.
slice
public abstract CharBuffer slice()
- Creates a new
CharBufferwhose content is a shared subsequence of this buffer's content.
duplicate
public abstract CharBuffer duplicate()
- Creates a new
CharBufferthat shares this buffer's content.
asReadOnlyBuffer
public abstract CharBuffer asReadOnlyBuffer()
- Creates a new read-only
CharBufferthat shares this buffer's content.
toString
public java.lang.String toString()
- Returns the remaining content of the buffer as a string.
- Specified by:
toStringin interfacejava.lang.CharSequence
length
public final int length()
- Returns the length of the remaining chars in this buffer.
- Specified by:
lengthin interfacejava.lang.CharSequence
subSequence
public abstract java.lang.CharSequence subSequence(int start, int length)
- Creates a new character buffer that represents the specified subsequence
of this buffer, relative to the current position.
- Specified by:
subSequencein interfacejava.lang.CharSequence
put
public CharBuffer put(java.lang.String str, int start, int length)
- Relative put method.
put
public final CharBuffer put(java.lang.String str)
- Relative put method.
charAt
public final char charAt(int index)
- Returns the character at
position() + index.- Specified by:
charAtin interfacejava.lang.CharSequence
|
|||||||||
| Home >> All >> java >> [ nio overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC