xbn.string
Class SOBStringBuffer

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.string.StringOrBuffer
              |
              +--xbn.string.SOBStringBuffer

public class SOBStringBuffer
extends StringOrBuffer

A StringOrBuffer that wraps around a java.lang.StringBuffer. See StringBuffer.

Source code:  SOBStringBuffer.java.  Unit tests:  See the unit tests for StringOrBuffer.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
SOBStringBuffer(String s_tr)
          Create an SOBStringBuffer.
SOBStringBuffer(StringBuffer str_buffer)
          Create an SOBStringBuffer.
 
Method Summary
 void append(char c_toAppend)
          Append a character onto the end (right).
 void append(String s_toAppend)
          Append a string onto the end (right).
 void appendToLeft(char c_toAppend)
          Append a character onto the start.
 void appendToLeft(String s_toAppend)
          Append a string onto the start.
 char charAt(int i_dx)
          Get the character located at the requested array index.
 void delete(int i_idxLeft, int i_idxAfterRight)
          Delete a range of characters.
 void deleteCharAt(int i_dx)
          Delete a character.
 boolean endsWith(String s_toSearchFor)
          Is the search string found at the end of the StringOrBuffer?
 StringBuffer getStringBuffer()
          Get the StringBuffer for direct manipulation.
 String getTrimmed()
          Get the value of this StringOrBuffer, after trimming whitespace from the ends.
 void insert(int i_dx, char c_toInsert)
          Insert a character.
 void insert(int i_dx, String s_toInsert)
          Insert a string.
 boolean isString()
          Does this StringOrBuffer contain a String?
 int length()
          How long is this StringOrBuffer?
 void setLength(int i_newLength)
          Set the length.
 boolean startsWith(String s_toSearchFor)
          Is the search string found at index 0?
 String substring(int i_idxLeft)
          Get a range of characters starting at the requested index.
 String substring(int i_idxLeft, int i_idxAfterRight)
          Get a range of characters.
 String toString()
          Get some information about this SOBStringBuffer.
 void trim()
          Trim whitespace from the value of this StringOrBuffer.
 
Methods inherited from class xbn.string.StringOrBuffer
deleteAll, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, isEmpty, isStringAt, isStringBuffer, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SOBStringBuffer

public SOBStringBuffer(String s_tr)

Create an SOBStringBuffer.

Parameters:
s_tr - May not be null.

SOBStringBuffer

public SOBStringBuffer(StringBuffer str_buffer)

Create an SOBStringBuffer.

Parameters:
str_buffer - The StringBuffer to wrap around. May not be null.
Method Detail

getStringBuffer

public final StringBuffer getStringBuffer()

Get the StringBuffer for direct manipulation.

Returns:
The internally-held StringBuffer.

isString

public final boolean isString()
Description copied from class: StringOrBuffer

Does this StringOrBuffer contain a String?

Overrides:
isString in class StringOrBuffer
Returns:
false

toString

public final String toString()

Get some information about this SOBStringBuffer.

Overrides:
toString in class Object
Returns:
getStringBuffer().toString()

trim

public final void trim()

Trim whitespace from the value of this StringOrBuffer.

Equal to [TCInvisible].trim(getStringBuffer())

Overrides:
trim in class StringOrBuffer

getTrimmed

public final String getTrimmed()
Description copied from class: StringOrBuffer

Get the value of this StringOrBuffer, after trimming whitespace from the ends. This does not alter the internally-held value.

Overrides:
getTrimmed in class StringOrBuffer
Returns:
getStringBuffer().toString().trim()

charAt

public final char charAt(int i_dx)
Description copied from class: StringOrBuffer

Get the character located at the requested array index.

Overrides:
charAt in class StringOrBuffer
Returns:
getStringBuffer().charAt(i_dx)

append

public final void append(String s_toAppend)

Append a string onto the end (right).

First executes
   getStringBuffer().append(s_toAppend)

Overrides:
append in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
s_toAppend - The string to append.

appendToLeft

public final void appendToLeft(String s_toAppend)

Append a string onto the start.

Equal to insert(0, s_toAppend)

Overrides:
appendToLeft in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
s_toAppend - The string to append.

insert

public final void insert(int i_dx,
                         String s_toInsert)

Insert a string.

Equal to getStringBuffer().insert(i_dx, s_toInsert)

Overrides:
insert in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
i_dx - The array index at which s_toInsert should be inserted. Must range 0..[length() - 1], inclusive.
s_toInsert - The string to insert.

append

public final void append(char c_toAppend)

Append a character onto the end (right).

First executes
   getStringBuffer().append(c_toAppend)

Overrides:
append in class StringOrBuffer
Returns:
This SOBStringBuffer (as a StringOrBuffer).

appendToLeft

public final void appendToLeft(char c_toAppend)

Append a character onto the start.

Equal to insert(0, c_toAppend)

Overrides:
appendToLeft in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
c_toAppend - The character to insert.

insert

public final void insert(int i_dx,
                         char c_toInsert)

Insert a character.

Equal to getStringBuffer().insert(i_dx, c_toInsert)

Overrides:
insert in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
i_dx - The array index at which c_toInsert should be inserted. Must range 0..[length() - 1], inclusive.
c_toInsert - The character to insert.

deleteCharAt

public final void deleteCharAt(int i_dx)

Delete a character.

Equal to getStringBuffer().deleteCharAt(i_dx)

Overrides:
deleteCharAt in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
i_dx - The array index containing the character to delete. Must range 0..[length() - 1], inclusive.

delete

public final void delete(int i_idxLeft,
                         int i_idxAfterRight)

Delete a range of characters.

Equal to getStringBuffer().delete(i_idxLeft, i_idxAfterRight)

Overrides:
delete in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
i_idxLeft - The array index of the left-most character to be deleted. Must range 0..[length() - 1], inclusive, and must be less than or equal to i_idxAfterRight.
i_idxAfterRight - The array index after the right-most to be retrieved. Must be between i_idxLeft and length, inclusive.

setLength

public final void setLength(int i_newLength)

Set the length.

Equal to getStringBuffer().setLength(i_newLength)

Overrides:
setLength in class StringOrBuffer
Following copied from class: xbn.string.StringOrBuffer
Parameters:
i_newLength - The desired length. If less than length, then every character at and after (array index) i_newLength is deleted. If greater than length, then spaces are appended to the right hand side until the new length is achieved.

startsWith

public final boolean startsWith(String s_toSearchFor)
Description copied from class: StringOrBuffer

Is the search string found at index 0?

Overrides:
startsWith in class StringOrBuffer
Returns:
isStringAt(s_toSearchFor, 0) If s_toSearchFor.length is greater than or equal to length.
false If s_toSearchFor.length is less than length.

endsWith

public final boolean endsWith(String s_toSearchFor)
Description copied from class: StringOrBuffer

Is the search string found at the end of the StringOrBuffer?

Overrides:
endsWith in class StringOrBuffer
Returns:
isStringAt(s_toSearchFor, (length() - s_toSearchFor.length())) If s_toSearchFor.length is greater than or equal to length.
false If s_toSearchFor.length is less than length.

length

public final int length()
Description copied from class: StringOrBuffer

How long is this StringOrBuffer?

Overrides:
length in class StringOrBuffer
Returns:
getStringBuffer().length()

substring

public final String substring(int i_idxLeft)
Description copied from class: StringOrBuffer

Get a range of characters starting at the requested index.

This returns the same thing as substring(i_idxLeft, (length() - 1))

Overrides:
substring in class StringOrBuffer
Returns:
getStringBuffer().substring(i_idxLeft)

substring

public final String substring(int i_idxLeft,
                              int i_idxAfterRight)
Description copied from class: StringOrBuffer

Get a range of characters.

See substring.

Overrides:
substring in class StringOrBuffer
Returns:
getStringBuffer().substring(i_idxLeft, i_idxAfterRight)



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo