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
-
SString()
- Constructs a new SString which contains an empty string.
-
SString(SString)
- Constructs a new SString containing the same string as the
SString given as parameter.
-
SString(String)
- Constructs a new SString containing the string given as parameter.
-
append(char)
-
-
append(SString)
-
-
append(String)
-
-
between(String, String, boolean)
-
-
breakAt(String)
- Breaks this string at a separator.
-
breakAtAnyCharOf(String)
-
Breaks the string where any one separator of the characters given as parameter
appears.
-
endsWith(String)
-
-
equals(String)
-
-
getAfterFirst(String)
- Get the part of this string that appears after a delimiter.
-
getAfterFirst(String, boolean)
- Get the part of this string that appears after a delimiter.
-
getAfterLast(String)
-
-
getBeforeFirst(String)
-
-
getBeforeFirst(String, boolean)
-
-
getBeforeLast(String)
- Get the part of this string that appears before a delimiter.
-
indexOf(String)
-
-
indexOf(String, boolean)
-
-
indexOf(String, int)
-
-
indexOf(String, int, boolean)
-
-
indexOfIgnoreCase(String)
-
-
insert(int, String)
-
-
lastIndexOf(String)
-
-
length()
-
-
main(String[])
- Tests the class.
-
niceSubstring(int, int)
-
-
removeRegion(int, int)
-
-
replace(String, String)
- Replace substrings within the SString.
-
skipAfterAndIncludingLast(String)
- Removes the part of this string that appears after a delimiter.
-
substring(int)
-
-
substring(int, int)
-
-
substring(String, String, boolean)
-
-
substringIgnoreCase(String, String)
-
-
toInt()
-
-
toString()
- Returns a string representation of the object.
SString
public SString()
- Constructs a new SString which contains an empty string.
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.
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.
main
public static void main(String args[])
- Tests the class.
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.
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
removeRegion
public void removeRegion(int startPos,
int endPos)
insert
public void insert(int insertPos,
String s)
getBeforeFirst
public SString getBeforeFirst(String s)
getBeforeFirst
public SString getBeforeFirst(String s,
boolean ignoreCase)
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
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
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
getAfterLast
public SString getAfterLast(String s)
niceSubstring
public SString niceSubstring(int from,
int to)
append
public void append(String s)
append
public void append(char c)
append
public void append(SString s)
indexOf
public int indexOf(String s,
boolean ignoreCase)
indexOfIgnoreCase
public int indexOfIgnoreCase(String s)
indexOf
public int indexOf(String s,
int fromIndex,
boolean ignoreCase)
substring
public SString substring(String from,
String to,
boolean ignoreCase)
substringIgnoreCase
public SString substringIgnoreCase(String from,
String to)
between
public SString between(String from,
String to,
boolean ignoreCase)
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
String
s.
The returned array does not include any appearance of separator
.
Two consecutive separator
s 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
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.
toInt
public int toInt()
toString
public String toString()
- Returns a string representation of the object.
- Overrides:
- toString in class Object
equals
public boolean equals(String s)
substring
public SString substring(int from,
int to)
substring
public SString substring(int from)
length
public int length()
indexOf
public int indexOf(String s)
indexOf
public int indexOf(String s,
int fromIndex)
lastIndexOf
public int lastIndexOf(String s)
endsWith
public boolean endsWith(String suffix)
All Packages Class Hierarchy This Package Previous Next Index