All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class net.strandberg.text.SString

java.lang.Object
   |
   +----net.strandberg.text.SString

public final class SString
extends Object
Class SString is basically an extension to the java.lang.StringBuffer class although it does not explicitly do extends on StringBuffer (this as String and StringBuffer are final classes). The SString adds methods for replacing a string within the SString with another string. It also adds to the substring methods of String while at the same time incorporating the append method from StringBuffer.

Version:
$Revision: 0.6 $
Author:
Mats Strandberg
See Also:
StringBuffer, String

Constructor Index

 o SString()
Constructs a new SString which contains an empty string.
 o SString(SString)
Constructs a new SString containing the same string as the SString given as parameter.
 o SString(String)
Constructs a new SString containing the string given as parameter.

Method Index

 o append(char)
 o append(SString)
 o append(String)
 o between(String, String, boolean)
 o breakAt(String)
Breaks this string at a separator.
 o breakAtAnyCharOf(String)
Breaks the string where any one separator of the characters given as parameter appears.
 o endsWith(String)
 o equals(String)
 o getAfterFirst(String)
Get the part of this string that appears after a delimiter.
 o getAfterFirst(String, boolean)
Get the part of this string that appears after a delimiter.
 o getAfterLast(String)
 o getBeforeFirst(String)
 o getBeforeFirst(String, boolean)
 o getBeforeLast(String)
Get the part of this string that appears before a delimiter.
 o indexOf(String)
 o indexOf(String, boolean)
 o indexOf(String, int)
 o indexOf(String, int, boolean)
 o indexOfIgnoreCase(String)
 o insert(int, String)
 o lastIndexOf(String)
 o length()
 o main(String[])
Tests the class.
 o niceSubstring(int, int)
 o removeRegion(int, int)
 o replace(String, String)
Replace substrings within the SString.
 o skipAfterAndIncludingLast(String)
Removes the part of this string that appears after a delimiter.
 o substring(int)
 o substring(int, int)
 o substring(String, String, boolean)
 o substringIgnoreCase(String, String)
 o toInt()
 o toString()
Returns a string representation of the object.

Constructors

 o SString
 public SString()
Constructs a new SString which contains an empty string.

 o SString
 public SString(String s)
Constructs a new SString containing the string given as parameter.

Parameters:
s - the initial string to be contained in the SString.
 o SString
 public SString(SString s)
Constructs a new SString containing the same string as the SString given as parameter.

Parameters:
is - the SString to be copied by this SString.

Methods

 o main
 public static void main(String args[])
Tests the class.

 o replace
 public void replace(String out,
                     String in)
Replace substrings within the SString. All occurences of the string given as parameter are replaced.

Parameters:
out - string to be replaced.
in - new string to replace all occurences of out.
 o skipAfterAndIncludingLast
 public void skipAfterAndIncludingLast(String delimiter)
Removes the part of this string that appears after a delimiter. The method will search this SString for the last appearence of delimiter and remove the part of this SString that appears after this last delimiter. The last appearence of delimiter is also removed.

Parameters:
delimiter - the string used to shrink this string
 o removeRegion
 public void removeRegion(int startPos,
                          int endPos)
 o insert
 public void insert(int insertPos,
                    String s)
 o getBeforeFirst
 public SString getBeforeFirst(String s)
 o getBeforeFirst
 public SString getBeforeFirst(String s,
                               boolean ignoreCase)
 o getBeforeLast
 public SString getBeforeLast(String delimiter)
Get the part of this string that appears before a delimiter. The method will search this SString for the last appearence of delimiter and return the part of this SString that appears before the last delimiter, delimiter excluded. This SString itself is left untouched.

Parameters:
delimiter - the string used to select the substring
Returns:
the part of this string that appears before the last appearence of delimiter or an empty string if delimiter does not appear in this string
 o getAfterFirst
 public SString getAfterFirst(String delimiter)
Get the part of this string that appears after a delimiter. The method will search this SString for the first appearence of delimiter and return the rest of this SString, delimiter excluded. This SString itself is left untouched.

Parameters:
delimiter - the string used to select the substring
Returns:
the part of this string that appears after delimiter or an empty string if delimiter does not appear in this string
 o getAfterFirst
 public SString getAfterFirst(String delimiter,
                              boolean ignoreCase)
Get the part of this string that appears after a delimiter. The method will search this SString for the first appearence of delimiter and return the rest of this SString, delimiter excluded. This SString itself is left untouched.

Parameters:
delimiter - the string used to select the substring
ignoreCase - if true case will be ignored, if false the string matching will be case sensitive
Returns:
the part of this string that appears after delimiter or an empty string if delimiter does not appear in this string
 o getAfterLast
 public SString getAfterLast(String s)
 o niceSubstring
 public SString niceSubstring(int from,
                              int to)
 o append
 public void append(String s)
 o append
 public void append(char c)
 o append
 public void append(SString s)
 o indexOf
 public int indexOf(String s,
                    boolean ignoreCase)
 o indexOfIgnoreCase
 public int indexOfIgnoreCase(String s)
 o indexOf
 public int indexOf(String s,
                    int fromIndex,
                    boolean ignoreCase)
 o substring
 public SString substring(String from,
                          String to,
                          boolean ignoreCase)
 o substringIgnoreCase
 public SString substringIgnoreCase(String from,
                                    String to)
 o between
 public SString between(String from,
                        String to,
                        boolean ignoreCase)
 o breakAt
 public String[] breakAt(String separator)
Breaks this string at a separator. This string is broken into a number of strings, returned as an array of Strings. The returned array does not include any appearance of separator. Two consecutive separators in the string will result in an empty string being part of the returned result. This means that a string containing N delimiters will always return N+1 strings in the array. The method is case sensitive. This SString itself is left untouched.

Parameters:
separator - the string used to break this SString
Returns:
the array of strings representing the separated SString
 o breakAtAnyCharOf
 public String[] breakAtAnyCharOf(String delimiters)
Breaks the string where any one separator of the characters given as parameter appears. Two consecutive delimiters is interpreted as an empty field, resulting in an empty string. This means that a string containing N delimiters will always return N+1 strings in the array. If the delimiters are "\t\n", the string "\thi\nho\t\t" will be broken into the strings "", "hi", "ho", "" and "".
This SString itself is left untouched.

 o toInt
 public int toInt()
 o toString
 public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object
 o equals
 public boolean equals(String s)
 o substring
 public SString substring(int from,
                          int to)
 o substring
 public SString substring(int from)
 o length
 public int length()
 o indexOf
 public int indexOf(String s)
 o indexOf
 public int indexOf(String s,
                    int fromIndex)
 o lastIndexOf
 public int lastIndexOf(String s)
 o endsWith
 public boolean endsWith(String suffix)

All Packages  Class Hierarchy  This Package  Previous  Next  Index