jlibs.core.lang
Class CharArray

java.lang.Object
  extended by jlibs.core.lang.CharArray
All Implemented Interfaces:
CharSequence

public class CharArray
extends Object
implements CharSequence

This is CharSequence implementation.

Author:
Santhosh Kumar T

Constructor Summary
CharArray(char[] buff)
          Allocates a new CharArray so that it represents the sequence of characters currently contained in the character array argument.
CharArray(char[] buff, int offset, int length)
          Allocates a new CharArray that contains characters from a subarray of the character array argument.
 
Method Summary
 CharArrayReader asReader()
          creates a new CharArrayReader to read contents of this chararray
 char[] buffer()
          returns the char buffer used by this instance
 char charAt(int index)
           
 int length()
           
 int offset()
          returns the index of first character in char buffer
 void set(char[] buff, int offset, int length)
          replaces the internal char buffer with the given char array.
 CharSequence subSequence(int start, int end)
           
 char[] toCharArray(boolean clone)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharArray

public CharArray(char[] buff)
Allocates a new CharArray so that it represents the sequence of characters currently contained in the character array argument. The contents of the character array are not copied;

Parameters:
buff - value of the chararray

CharArray

public CharArray(char[] buff,
                 int offset,
                 int length)
Allocates a new CharArray that contains characters from a subarray of the character array argument. The offset argument is the index of the first character of the subarray and the length argument specifies the length of the subarray. The contents of the subarray are not copied;

Parameters:
buff - Array that is the source of characters
offset - The initial offset
length - The length
Throws:
IndexOutOfBoundsException - If the offset and length arguments index characters outside the bounds of the buff array
Method Detail

set

public void set(char[] buff,
                int offset,
                int length)
replaces the internal char buffer with the given char array.

Parameters:
buff - Array that is the source of characters
offset - The initial offset
length - The length

buffer

public char[] buffer()
returns the char buffer used by this instance


offset

public int offset()
returns the index of first character in char buffer


length

public int length()
Specified by:
length in interface CharSequence

toCharArray

public char[] toCharArray(boolean clone)

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

asReader

public CharArrayReader asReader()
creates a new CharArrayReader to read contents of this chararray


toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object


Copyright © 2018. All rights reserved.