Framework Professional Edition Package


com.prosyst.util.string
Class CharBuffer

java.lang.Object
  extended by com.prosyst.util.string.CharBuffer

public class CharBuffer
extends java.lang.Object

Class which stores text in a char array buffer and allows inserting, deleting, removing, appending etc. actions with the stored text.


Constructor Summary
CharBuffer()
          Constructs an object of this class.
CharBuffer(int length)
          Constructs an object of this class with specified length of buffer.
 
Method Summary
 void append(char c)
          Appends a char at the end of this buffer.
 void append(char[] str)
          Appends a char array at the end of this class one.
 void append(char[] str, int offset, int len)
           
 void append(java.lang.String str)
          Appends a string at the end of this buffer.
 char charAt(int index)
          Returns a char at a specified index of this buffer.
 void ensureCapacity(int minimumCapacity)
          Ensures that the capacity of the buffer is at least equal to the specified minimum.
 boolean equals(int offset, java.lang.String with)
           
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
           
 char[] getValue()
          Returns text as a char array.
 int length()
          Returns the length of this char buffer.
 void setCharAt(int index, char ch)
          Replaces a char in specified index in the buffer with another one.
 void setLength(int newLength)
          Sets a new length to this buffer.
 java.lang.String substring(int start, int end)
          Returns substring from this buffer.
 java.lang.String toString()
          Makes a string representation of this buffer.
 java.lang.String trim()
          Removes white space from both ends of this string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharBuffer

public CharBuffer()
Constructs an object of this class.


CharBuffer

public CharBuffer(int length)
Constructs an object of this class with specified length of buffer.

Parameters:
length - initial lenght of the char array
Method Detail

length

public int length()
Returns the length of this char buffer.

Returns:
length of this char buffer

ensureCapacity

public void ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum. If the current capacity of this buffer is smaller than the argument, then a new internal with greater capacity buffer is allocated.

Parameters:
minimumCapacity - minimum value of the capacity

setLength

public void setLength(int newLength)
Sets a new length to this buffer.

Parameters:
newLength - the new length

charAt

public char charAt(int index)
Returns a char at a specified index of this buffer.

Parameters:
index - the index of the searched char
Returns:
the searched char.

setCharAt

public void setCharAt(int index,
                      char ch)
Replaces a char in specified index in the buffer with another one.

Parameters:
index - the index of the searched char
ch - the specified char

append

public void append(java.lang.String str)
Appends a string at the end of this buffer.

Parameters:
str - the string to be appended

append

public void append(char[] str,
                   int offset,
                   int len)

append

public void append(char[] str)
Appends a char array at the end of this class one.

Parameters:
str - the array to be appended

append

public void append(char c)
Appends a char at the end of this buffer.

Parameters:
c - the char to be appended

substring

public java.lang.String substring(int start,
                                  int end)
Returns substring from this buffer.

Parameters:
start - from where to start
end - where to end
Returns:
the whanted substring

trim

public java.lang.String trim()
Removes white space from both ends of this string.

If this String object represents an empty character sequence, or the first and last characters of character sequence represented by this String object both have codes greater than '\u0020' (the space character), then a reference to this String object is returned.

Otherwise, if there is no character with a code greater than '\u0020' in the string, then a new String object representing an empty string is created and returned.

Otherwise, let k be the index of the first character in the string whose code is greater than '\u0020', and let m be the index of the last character in the string whose code is greater than '\u0020'. A new String object is created, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(km+1).

This method may be used to trim whitespace from the beginning and end of a string; in fact, it trims all ASCII control characters as well.

Returns:
this string, with white space removed from the front and end.

equals

public boolean equals(int offset,
                      java.lang.String with)

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)

toString

public java.lang.String toString()
Makes a string representation of this buffer.

Overrides:
toString in class java.lang.Object
Returns:
the stored char array as String.

getValue

public char[] getValue()
Returns text as a char array.

Returns:
char array that is stored here.

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved