com.sapportals.portal.prt.util
Class SmartBuffer

java.lang.Object
  |
  +--com.sapportals.portal.prt.util.SmartBuffer

public class SmartBuffer
extends java.lang.Object

Implements a character buffer that can be substituted with the StringBuffer.Note that this class is not thread safe.
The internal buffer is created by default with a size of 32 Charaters. It automatically expands its buffer. Due to its usage, the initial buffer is never recreated is the buffer is reset. Copyright (c) SAP Portals Europe GmbH 2001

Version:
$Revision: $

Field Summary
protected  char[] m_buff
           
protected  int m_length
           
 boolean m_shared
           
 
Method Summary
 SmartBuffer append(char ch)
           
 SmartBuffer append(char[] c)
           
 SmartBuffer append(char[] str, int o, int len)
           
 SmartBuffer append(double d)
          Appends the string representation of a double value to the buffer
 SmartBuffer append(int i)
           
 SmartBuffer append(java.lang.String str)
           
 int capacity()
           
 char charAt(int index)
          The specified character of the sequence currently represented by the string buffer, as indicated by the index argument, is returned.
 void ensureCapacity(int minimumCapacity)
           
 int length()
           
 void reset()
           
 void setCharAt(int index, char ch)
          The character at the specified index of this string buffer is set to ch.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_shared

public boolean m_shared

m_buff

protected char[] m_buff

m_length

protected int m_length
Method Detail

append

public final SmartBuffer append(char ch)
Parameters:
ch -  

append

public final SmartBuffer append(int i)
Parameters:
i -  

ensureCapacity

public final void ensureCapacity(int minimumCapacity)
Parameters:
minimumCapacity -  

append

public SmartBuffer append(char[] str,
                          int o,
                          int len)
Parameters:
str[] -  
o -  
len -  

append

public SmartBuffer append(char[] c)
Parameters:
c[] -  

append

public SmartBuffer append(java.lang.String str)
Parameters:
str -  

charAt

public char charAt(int index)
The specified character of the sequence currently represented by the string buffer, as indicated by the index argument, is returned. The first character of a string buffer is at index 0, the next at index 1, and so on, for array indexing.

The index argument must be greater than or equal to 0, and less than the length of this string buffer.

Parameters:
index - the index of the desired character.
Returns:
the character at the specified index of this string buffer.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to length().
See Also:
StringBuffer.length()

setCharAt

public void setCharAt(int index,
                      char ch)
The character at the specified index of this string buffer is set to ch. The string buffer is altered to represent a new character sequence that is identical to the old character sequence, except that it contains the character ch at position index.

The offset argument must be greater than or equal to 0, and less than the length of this string buffer.

Parameters:
index - the index of the character to modify.
ch - the new character.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to length().
See Also:
StringBuffer.length()

append

public SmartBuffer append(double d)
Appends the string representation of a double value to the buffer
Parameters:
d -  

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

length

public final int length()

capacity

public final int capacity()

reset

public final void reset()