|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcdx.scorebot.util.StringOps
public abstract class StringOps
Defines some methods for matching and replacement on special conditions for Strings.
| Constructor Summary | |
|---|---|
StringOps()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
checkName(java.lang.String name)
Checks to see if name contains anything other than alphanumeric characters, underscores, or spaces. |
static java.lang.String |
endWithSlash(java.lang.String s)
make sure the last character in the specified String is a slash unless s is of length 0 in which case the empty string passed in is returned |
static java.lang.String |
getFileAsString(java.lang.String fn)
Gets the contents of a file as a String |
static java.lang.String |
getFileTitle(java.lang.String s)
Gets the text following the last slash (\ or /) in a string (the "file title") |
static java.lang.String |
getPath(java.lang.String fn)
determine the path in the string (all text before and included the last slash mark, or the empty string if there are no slashes) |
static int |
indexOf(java.lang.String s,
java.lang.String searchTerm)
finds the searchTerm in String s from startIndex which doesn't have a letter, digit, or underscore on either side of it |
static int |
indexOf(java.lang.String s,
java.lang.String searchTerm,
int startIndex)
finds the searchTerm in String s from startIndex which doesn't have a letter, digit, or underscore on either side of it |
static java.lang.String |
replace(java.lang.String s,
java.lang.String searchTerm,
java.lang.String replaceTerm)
replaces all occurs of searchTerm in s which don't have a letter, digit, or underscore on either side |
static java.lang.String |
replaceBetweenStrings(java.lang.String str,
java.lang.String s1,
java.lang.String s2,
java.lang.String repl)
Replaces the text between two strings (and removes the specified strings themselves too) |
static java.lang.String |
selectBetweenStrings(java.lang.String str,
java.lang.String s1,
java.lang.String s2)
Selects the text between two strings |
static java.lang.String |
splitIntoLines(java.lang.String s)
inserts a newline after every 80 characters |
static java.lang.String |
splitIntoLines(java.lang.String s,
int maxLineLen)
inserts a newline after every maxLineLen characters |
static java.lang.String |
splitIntoLines(java.lang.String s,
int firstLineMaxLen,
int maxLineLen,
java.lang.String newlineIdentifier,
boolean trim)
inserts a newline string specified by the user after every maxLineLen characters |
static java.lang.String |
splitIntoLines(java.lang.String s,
int maxLineLen,
java.lang.String newlineIdentifier,
boolean trim)
inserts a newline string specified by the user after every maxLineLen characters |
static java.lang.String |
stripExtensions(java.lang.String s,
int numExtToStrip)
Removes a specified number of extensions from s |
static void |
writeStringToFile(java.lang.String fn,
java.lang.String str)
Writes a string to a file |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringOps()
| Method Detail |
|---|
public static java.lang.String checkName(java.lang.String name)
throws IllegalArgValException
IllegalArgValException - occurs if the name is invalid.public static java.lang.String endWithSlash(java.lang.String s)
public static java.lang.String getPath(java.lang.String fn)
fn - the filename to find the path in
public static java.lang.String getFileAsString(java.lang.String fn)
throws java.io.IOException
java.io.Exception - occurs if the file is invalid or unable to be properly read
java.io.IOExceptionpublic static java.lang.String getFileTitle(java.lang.String s)
s - the string to work with
public static java.lang.String stripExtensions(java.lang.String s,
int numExtToStrip)
s - the string to remove extensions from (.ext)numExtToStrip - the number of extensions to remove
public static java.lang.String replace(java.lang.String s,
java.lang.String searchTerm,
java.lang.String replaceTerm)
s - the string being searchedsearchTerm - what is being searched forreplaceTerm - what searchTerm is being replaced with
public static java.lang.String replaceBetweenStrings(java.lang.String str,
java.lang.String s1,
java.lang.String s2,
java.lang.String repl)
str - the string to searchs1 - the first string to finds2 - the second string to findrepl - the string to use to replace the range from the beginning s1 to the end s2 inclusive
public static java.lang.String selectBetweenStrings(java.lang.String str,
java.lang.String s1,
java.lang.String s2)
str - the string to searchs1 - the first string to finds2 - the second string to find
public static void writeStringToFile(java.lang.String fn,
java.lang.String str)
throws java.io.IOException
fn - the file to write the string tostr - the string to write
java.io.IOException
public static int indexOf(java.lang.String s,
java.lang.String searchTerm)
s - the string being searchedsearchTerm - what is being searched for
public static int indexOf(java.lang.String s,
java.lang.String searchTerm,
int startIndex)
s - the string being searchedsearchTerm - what is being searched forstartIndex - where to start lookingpublic static java.lang.String splitIntoLines(java.lang.String s)
s - the string to split
public static java.lang.String splitIntoLines(java.lang.String s,
int maxLineLen)
s - the string to splitmaxLineLen - the max length (in characters) a line may be
public static java.lang.String splitIntoLines(java.lang.String s,
int maxLineLen,
java.lang.String newlineIdentifier,
boolean trim)
s - the string to splitmaxLineLen - the max length (in characters) a line may benewlineIdentifier - the string to use to split lines uptrim - whether or not trim whitespace of each line's ends
public static java.lang.String splitIntoLines(java.lang.String s,
int firstLineMaxLen,
int maxLineLen,
java.lang.String newlineIdentifier,
boolean trim)
s - the string to splitfirstLineMaxLen - the max length (in characters) the first line may bemaxLineLen - the max length (in characters) a line may benewlineIdentifier - the string to use to split lines uptrim - whether or not trim whitespace of each line's ends
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||