Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.nio
Class CharBuffer  view CharBuffer download CharBuffer.java

java.lang.Object
  extended byjava.nio.Buffer
      extended byjava.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

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 CharBuffer object with a given capacity.


wrap

public static final CharBuffer wrap(char[] array,
                                    int offset,
                                    int length)
Wraps a char array into a CharBuffer object.


wrap

public static final CharBuffer wrap(java.lang.CharSequence seq)
Wraps a character sequence into a CharBuffer object.


wrap

public static final CharBuffer wrap(java.lang.CharSequence seq,
                                    int start,
                                    int end)
Wraps a character sequence into a CharBuffer object.


wrap

public static final CharBuffer wrap(char[] array)
Wraps a char array into a CharBuffer object.


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 length chars 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 CharBUFFER src into the buffer. Before the transfer, it checks if there is fewer than src.remaining() space remaining in this buffer.


put

public CharBuffer put(char[] src,
                      int offset,
                      int length)
Writes the content of the the char array src 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 array src into the buffer.


hasArray

public final boolean hasArray()
Tells whether ot not this buffer is backed by an accessible char array.


array

public final char[] array()
Returns the char array 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 CharBuffer objects.

Specified by:
compareTo in interface java.lang.Comparable

order

public abstract ByteOrder order()
Returns the byte order of this buffer.


get

public abstract char get()
Reads the char at this buffer's current position, and then increments the position.


put

public abstract CharBuffer put(char b)
Writes the char at 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 CharBuffer whose content is a shared subsequence of this buffer's content.


duplicate

public abstract CharBuffer duplicate()
Creates a new CharBuffer that shares this buffer's content.


asReadOnlyBuffer

public abstract CharBuffer asReadOnlyBuffer()
Creates a new read-only CharBuffer that shares this buffer's content.


toString

public java.lang.String toString()
Returns the remaining content of the buffer as a string.

Specified by:
toString in interface java.lang.CharSequence

length

public final int length()
Returns the length of the remaining chars in this buffer.

Specified by:
length in interface java.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:
subSequence in interface java.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:
charAt in interface java.lang.CharSequence