|
Colt 1.0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ViolinStrings.Strings
The Strings
class provides a number of useful string manipulation
methods. It cannot be instantiated.
You would typically use it in the following manner:
String s = "abcdefg"; String x = Strings.leftJustify(s, 20);
Some of the methods just call the equivalent methods from java.lang.String. They are provided to collect all string methods in one place.
String
,
StringBuffer
,
Character
Method Summary | |
static String |
center(String s,
int len)
Centers the string within a string of the specified length, padding it with blanks. |
static String |
center(String s,
int len,
char pad)
Centers the string within a string of the specified length, padding it with the specified character. |
static String |
change(String s,
char oldc,
char newc)
Changes occurrences of a specified character to a replacement character. |
static String |
change(String s,
char oldc,
char newc,
int start)
Changes occurrences of a specified character to a replacement character. |
static String |
change(String s,
char oldc,
char newc,
int start,
boolean ignoreCase)
Changes occurrences of a specified character to a replacement character. |
static String |
change(String s,
char oldc,
char newc,
int start,
int maxChanges)
Changes occurrences of a specified character to a replacement character. |
static String |
change(String s,
char oldc,
char newc,
int start,
int maxChanges,
boolean ignoreCase)
Changes occurrences of a specified character to a replacement character. |
static String |
change(String s,
String oldp,
String newp)
Changes occurrences of a specified pattern to a replacement string. |
static String |
change(String s,
String oldp,
String newp,
boolean ignoreCase)
Changes occurrences of a specified pattern to a replacement string. |
static String |
change(String s,
String oldp,
String newp,
int start)
Changes occurrences of a specified pattern to a replacement string. |
static String |
change(String s,
String oldp,
String newp,
int start,
boolean ignoreCase)
Changes occurrences of a specified pattern to a replacement string. |
static String |
change(String s,
String oldp,
String newp,
int start,
int maxChanges)
Changes occurrences of a specified pattern to a replacement string. |
static String |
change(String s,
String oldp,
String newp,
int start,
int maxChanges,
boolean ignoreCase)
Changes occurrences of a specified pattern to a replacement string. |
static int |
compare(String s1,
String s2)
Compares two strings. |
static boolean |
contains(String s,
String search)
Returns true if the specified search string is contained in the original string. |
static boolean |
contains(String s,
String search,
boolean ignoreCase)
Returns true if the specified search string is contained in the original string. |
static String |
copies(String s,
int nCopies)
Returns a string consisting of the specified number of copies of the input string. |
static boolean |
endsWith(String s,
String suffix)
Returns true if the string ends with the specified suffix. |
static boolean |
endsWith(String s,
String suffix,
boolean ignoreCase)
Returns true if the string ends with the specified suffix. |
static boolean |
equals(char c1,
char c2,
boolean ignoreCase)
Checks if two characters are equal. |
static boolean |
equals(String s1,
String s2,
boolean ignoreCase)
Checks if two strings are equal. |
static int |
indexOf(String s,
char c)
Returns the index of the first ocurrence of the specified character. |
static int |
indexOf(String s,
char c,
boolean ignoreCase)
Returns the index of the first ocurrence of the specified character. |
static int |
indexOf(String s,
char c,
int start)
Returns the index of the first ocurrence of the specified character. |
static int |
indexOf(String s,
char c,
int start,
boolean ignoreCase)
Returns the index of the first ocurrence of the specified character, starting at the specified position. |
static int |
indexOf(String s,
String c)
Returns the index of the first ocurrence of the specified string. |
static int |
indexOf(String s,
String c,
boolean ignoreCase)
Returns the index of the first ocurrence of the specified string, starting at the beginning of the string. |
static int |
indexOf(String s,
String c,
int start)
Returns the index of the first ocurrence of the specified string. |
static int |
indexOf(String s,
String c,
int start,
boolean ignoreCase)
Returns the index of the first ocurrence of the specified string. |
static int |
indexOfAnyBut(String s,
String c)
Returns the index of the first character that is not contained in the specified set of characters. |
static int |
indexOfAnyBut(String s,
String c,
boolean ignoreCase)
Returns the index of the first character that is not contained in the specified set of characters. |
static int |
indexOfAnyBut(String s,
String c,
int start)
Returns the index of the first character that is not contained in the specified set of characters. |
static int |
indexOfAnyBut(String s,
String c,
int start,
boolean ignoreCase)
Returns the index of the first character that is not contained in the specified set of characters. |
static int |
indexOfAnyOf(String s,
String c)
Returns the index of the first character that is contained in the specified set of characters. |
static int |
indexOfAnyOf(String s,
String c,
boolean ignoreCase)
Returns the index of the first character that is contained in the specified set of characters. |
static int |
indexOfAnyOf(String s,
String c,
int start)
Returns the index of the first character that is contained in the specified set of characters. |
static int |
indexOfAnyOf(String s,
String c,
int start,
boolean ignoreCase)
Returns the index of the first character that is contained in the specified set of characters. |
static int |
indexOfPhrase(String s,
String p,
int startWord)
Returns the index of the first occurrence of the specified phrase within the string. |
static int |
indexOfPhrase(String s,
String p,
int startWord,
boolean ignoreCase)
Returns the index of the first occurrence of the specified phrase within the string. |
static int |
indexOfWord(String s,
int wordNum)
Returns the index of the first character of the specified nth word within the string. |
static String |
insert(String s,
String ins,
int start)
Inserts a string after the specified position. |
static String |
insert(String s,
String ins,
int start,
char pad)
Inserts a string after the specified position. |
static boolean |
isAbbreviationOf(String s,
String full,
boolean ignoreCase)
Returns true if the string is a valid abbreviation of another string. |
static boolean |
isAbbreviationOf(String s,
String full,
int minLength)
Returns true if the string is a valid abbreviation of another string. |
static boolean |
isAbbreviationOf(String s,
String full,
int minLength,
boolean ignoreCase)
Returns true if the string is a valid abbreviation of another string. |
static boolean |
isDigit(String s)
Returns true if the string consists of digits. |
static boolean |
isIdentifierIgnorable(String s)
Returns true if the string consists of ignorable characters in a Java identifier or a Unicode identifier. |
static boolean |
isISOControl(String s)
Returns true if the string consists of ISO control characters. |
static boolean |
isJavaIdentifier(String s)
Returns true if the string is a valid Java identifier. |
static boolean |
isLetter(String s)
Returns true if the string consists of letters. |
static boolean |
isLetterOrDigit(String s)
Returns true if the string consists of letters or digits. |
static boolean |
isLike(String s,
String pattern)
Returns true if the string matches the specified pattern. |
static boolean |
isLike(String s,
String pattern,
int start)
Returns true if the string matches the specified pattern. |
static boolean |
isLike(String s,
String pattern,
int start,
boolean ignoreCase)
Returns true if the string matches the specified pattern. |
static boolean |
isLike(String s,
String pattern,
int start,
char wAnySeq,
char wAnyChar,
boolean ignoreCase)
Returns true if the string matches the specified pattern. |
static boolean |
isLowerCase(String s)
Returns true if the string consists of lowercase characters. |
static boolean |
isSpaceChar(String s)
Returns true if the string consists of Unicode space characters. |
static boolean |
isTitleCase(String s)
Returns true if the string consists of title case characters. |
static boolean |
isUnicodeIdentifier(String s)
Returns true if the string is a valid Unicode identifier. |
static boolean |
isUpperCase(String s)
Returns true if the string consists of uppercase characters. |
static boolean |
isWhitespace(String s)
Returns true if the string consists of whitespace characters. |
static int |
lastIndexOf(String s,
char c)
Returns the index of the last ocurrence of the specified character. |
static int |
lastIndexOf(String s,
char c,
int start)
Returns the index of the last ocurrence of the specified character. |
static int |
lastIndexOf(String s,
char c,
int start,
boolean ignoreCase)
Returns the index of the last ocurrence of the specified character. |
static int |
lastIndexOf(String s,
String c)
Returns the index of the last ocurrence of the specified string. |
static int |
lastIndexOf(String s,
String c,
boolean ignoreCase)
Returns the index of the last ocurrence of the specified string. |
static int |
lastIndexOf(String s,
String c,
int start)
Returns the index of the last ocurrence of the specified string. |
static int |
lastIndexOf(String s,
String c,
int start,
boolean ignoreCase)
Returns the index of the last ocurrence of the specified string. |
static int |
lastIndexOfAnyBut(String s,
String c)
Returns the index of the last character that is not contained in the specified set of characters. |
static int |
lastIndexOfAnyBut(String s,
String c,
int start)
Returns the index of the last character that is not contained in the specified set of characters. |
static int |
lastIndexOfAnyBut(String s,
String c,
int start,
boolean ignoreCase)
Returns the index of the last character that is not contained in the specified set of characters. |
static int |
lastIndexOfAnyOf(String s,
String c)
Returns the index of the last character that is contained in the specified set of characters. |
static int |
lastIndexOfAnyOf(String s,
String c,
int start)
Returns the index of the last character that is contained in the specified set of characters. |
static int |
lastIndexOfAnyOf(String s,
String c,
int start,
boolean ignoreCase)
Returns the index of the last character that is contained in the specified set of characters. |
static String |
leftJustify(String s,
int len)
Left-justifies the string in a string of the specified length. |
static String |
leftJustify(String s,
int len,
char pad)
Left-justifies the string in a string of the specified length. |
static int |
numWords(String s)
Returns the number of words in the string. |
static int |
occurrencesOf(String s,
String c)
Returns the number of occurrences of the specified string. |
static int |
occurrencesOf(String s,
String c,
boolean ignoreCase)
Returns the number of occurrences of the specified string. |
static int |
occurrencesOf(String s,
String c,
int start)
Returns the number of occurrences of the specified string. |
static int |
occurrencesOf(String s,
String c,
int start,
boolean ignoreCase)
Returns the number of occurrences of the specified string. |
static String |
overlayWith(String s,
String o,
int start)
Replaces part of the string with the specified string, starting at a specified position. |
static String |
overlayWith(String s,
String o,
int start,
char pad)
Replaces part of the string with the specified string, starting at a specified position. |
static String |
remove(String s,
int start,
int numChars)
Removes the specified number of characters from the string, starting at the specified position. |
static String |
removeWords(String s,
int startWord,
int numWords)
Removes the specified number of words from the string, starting with the specified word number. |
static String |
reverse(String s)
Reverses the sequence of characters contained in the string. |
static String |
rightJustify(String s,
int len)
Right-justifies the string in a string of the specified length. |
static String |
rightJustify(String s,
int len,
char pad)
Right-justifies the string in a string of the specified length. |
static String[] |
split(String s)
Return an array of the constituent words of a string. |
static String[] |
split(String s,
int limit)
Return an array of (at most) the first limit constituent words of a string. |
static boolean |
startsWith(String s,
String prefix)
Returns true if the string starts with the specified prefix. |
static boolean |
startsWith(String s,
String prefix,
boolean ignoreCase)
Returns true if the string starts with the specified prefix. |
static boolean |
startsWith(String s,
String prefix,
int start)
Returns true if the string starts with the specified prefix. |
static boolean |
startsWith(String s,
String prefix,
int start,
boolean ignoreCase)
Returns true if the string starts with the specified prefix. |
static String |
strip(String s,
char c)
Strips the specified character from both ends of the string. |
static String |
strip(String s,
char c,
boolean ignoreCase)
Strips the specified character from both ends of the string. |
static String |
strip(String s,
String c)
Strips the specified characters from both ends of the string. |
static String |
strip(String s,
String c,
boolean ignoreCase)
Strips the specified characters from both ends of the string. |
static String |
stripBlanks(String s)
Strips white space characters from both ends of the string. |
static String |
stripLeading(String s,
char c)
Strips the specified leading character. |
static String |
stripLeading(String s,
char c,
boolean ignoreCase)
Strips the specified leading character. |
static String |
stripLeading(String s,
String c)
Strips the specified leading characters. |
static String |
stripLeading(String s,
String c,
boolean ignoreCase)
Strips the specified leading characters. |
static String |
stripLeadingBlanks(String s)
Strips leading white space characters. |
static String |
stripTrailing(String s,
char c)
Strips the specified trailing character. |
static String |
stripTrailing(String s,
char c,
boolean ignoreCase)
Strips the specified trailing character. |
static String |
stripTrailing(String s,
String c)
Strips the specified trailing characters. |
static String |
stripTrailing(String s,
String c,
boolean ignoreCase)
Strips the specified trailing characters. |
static String |
stripTrailingBlanks(String s)
Strips trailing white space characters. |
static String |
substring(String s,
int start)
Returns a substring of the specified string, starting at a specified position, and extending to the end of the string. |
static String |
substring(String s,
int start,
int len)
Returns a substring of the specified string, starting at a specified position, with the specified length. |
static String |
substring(String s,
int start,
int len,
char pad)
Returns a substring of the specified string, starting at a specified position, with the specified length. |
static String |
subWords(String s,
int startWord,
int numWords)
Returns a substring of the string which starts at a specified word and contains the specified number of words. |
static boolean |
toBoolean(String s)
Returns true if the string represents the word "true". |
static byte |
toByte(String s)
If the string represents a valid byte value, returns this value as a byte. |
static byte |
toByte(String s,
int radix)
If the string represents a valid byte value, returns this value as a byte. |
static double |
toDouble(String s)
If the string represents a valid double number, returns this number as a double value. |
static float |
toFloat(String s)
If the string represents a valid float number, returns this number as a float value. |
static int |
toInt(String s)
If the string represents a valid integer number, returns this number as an int value. |
static int |
toInt(String s,
int radix)
If the string represents a valid integer number, returns this number as an int value. |
static long |
toLong(String s)
If the string represents a valid long integer, returns this number as a long value. |
static long |
toLong(String s,
int radix)
If the string represents a valid long integer, returns this number as a long value. |
static String |
toLowerCase(String s)
Converts the string to lower case. |
static String |
toLowerCase(String s,
Locale locale)
Converts the string to lower case using the given Locale. |
static short |
toShort(String s)
If the string represents a valid short number, returns this number as a short value. |
static short |
toShort(String s,
int radix)
If the string represents a valid short number, returns this number as a short value. |
static String |
toTitleCase(String s)
Converts the string to titlecase. |
static String |
toUpperCase(String s)
Converts the string to upper case. |
static String |
toUpperCase(String s,
Locale locale)
Converts the string to upper case using the given Locale. |
static String |
translate(String s,
String setin,
String setout)
Converts all of the string's characters which are contained in the input set of characters to the corresponding character in the output set of characters. |
static String |
translate(String s,
String setin,
String setout,
boolean ignoreCase)
Converts all of the string's characters which are contained in the input set of characters to the corresponding character in the output set of characters. |
static String |
translate(String s,
String setin,
String setout,
char pad)
Converts all of the string's characters which are contained in the input set of characters to the corresponding character in the output set of characters. |
static String |
translate(String s,
String setin,
String setout,
char pad,
boolean ignoreCase)
Converts all of the string's characters which are contained in the input set of characters to the corresponding character in the output set of characters. |
static String |
word(String s,
int wordNum)
Returns the nth word in the string. |
static int |
wordIndexOfPhrase(String s,
String p,
int startWord)
Returns the number of the first word of the first occurrence of the specified phrase within the string. |
static int |
wordIndexOfPhrase(String s,
String p,
int startWord,
boolean ignoreCase)
Returns the number of the first word of the first occurrence of the specified phrase within the string. |
static String |
wordSpace(String s,
int spaces)
All whitespace between the words of the string is replaced by the specified number of blanks. |
static String |
xRange(char start,
char end)
Builds a string consisting of all characters between 'start' and 'end'. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static String center(String s, int len)
s
- the original stringlen
- the length of the new stringpublic static String center(String s, int len, char pad)
s
- the original stringlen
- the length of the new stringpad
- the pad characterpublic static String change(String s, char oldc, char newc)
s
- the input stringoldc
- the pattern to be replacednewc
- the replacement stringjava.lang.string#replace(char, char)
public static String change(String s, char oldc, char newc, int start)
s
- the input stringoldc
- the pattern to be replacednewc
- the replacement stringstart
- the starting position for the searchpublic static String change(String s, char oldc, char newc, int start, int maxChanges)
s
- the input stringoldc
- the pattern to be replacednewc
- the replacement stringstart
- the starting position for the searchmaxChanges
- the maximum number of changespublic static String change(String s, char oldc, char newc, int start, int maxChanges, boolean ignoreCase)
s
- the input stringoldc
- the pattern to be replacednewc
- the replacement stringstart
- the starting position for the searchmaxChanges
- the maximum number of changesignoreCase
- if true case is ignored when comparing characterspublic static String change(String s, char oldc, char newc, int start, boolean ignoreCase)
s
- the input stringoldc
- the pattern to be replacednewc
- the replacement stringstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characterspublic static String change(String s, String oldp, String newp)
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringpublic static String change(String s, String oldp, String newp, int start)
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the searchpublic static String change(String s, String oldp, String newp, int start, int maxChanges)
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the searchmaxChanges
- the maximum number of changespublic static String change(String s, String oldp, String newp, int start, int maxChanges, boolean ignoreCase)
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the searchmaxChanges
- the maximum number of changesignoreCase
- if true case is ignored when comparing characterspublic static String change(String s, String oldp, String newp, int start, boolean ignoreCase)
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characterspublic static String change(String s, String oldp, String newp, boolean ignoreCase)
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringignoreCase
- if true case is ignored when comparing characterspublic static int compare(String s1, String s2)
s1
- the first strings2
- second strings1
is lexicographically less than s2
,
and a value greater than
zero if s1
is lexicographically greater than s2
.java.lang.string#compareTo(String)
public static boolean contains(String s, String search)
s
- the original stringsearch
- the search stringjava.lang.string#indexOf(String)
public static boolean contains(String s, String search, boolean ignoreCase)
s
- the input stringsearch
- the search stringignoreCase
- if true case is ignored when comparing charactersjava.lang.string#indexOf(String)
public static String copies(String s, int nCopies)
s
- the input stringnCopies
- the number of copiesjava.lang.stringBuffer#append(String)
public static boolean endsWith(String s, String suffix)
s
- the input stringsuffix
- the suffixjava.lang.string#endsWith(String)
public static boolean endsWith(String s, String suffix, boolean ignoreCase)
s
- the input stringsuffix
- the suffixignoreCase
- if true case is ignored when comparing charactersjava.lang.string#endsWith(String)
,
java.lang.string#regionMatches(boolean, int, String, int, int)
public static boolean equals(char c1, char c2, boolean ignoreCase)
c1
- first characterc2
- second characterignoreCase
- if true case is ignored when comparing charactersjava.lang.string#equalsIgnoreCase(String)
public static boolean equals(String s1, String s2, boolean ignoreCase)
s1
- first strings2
- second stringignoreCase
- if true case is ignored when comparing charactersjava.lang.string#equalsIgnoreCase(String)
public static int indexOf(String s, char c)
s
- the string to be inspectedc
- the character to be searched forjava.lang.string#indexOf(char)
public static int indexOf(String s, char c, int start)
s
- the string to be inspectedc
- the character to be searched forstart
- the starting position for the searchjava.lang.string#indexOf(char, int)
public static int indexOf(String s, char c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the character to be searched forstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing charactersjava.lang.string#indexOf(char, int)
public static int indexOf(String s, char c, boolean ignoreCase)
s
- the string to be inspectedc
- the character to be searched forignoreCase
- if true case is ignored when comparing characterspublic static int indexOf(String s, String c)
s
- the string to be inspectedc
- the string to be searched forjava.lang.string#indexOf(String)
public static int indexOf(String s, String c, int start)
s
- the string to be inspectedc
- the string to be searched forstart
- the starting position for the searchjava.lang.string#indexOf(String, int)
public static int indexOf(String s, String c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the string to be searched forstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing charactersjava.lang.string#indexOf(String, int)
public static int indexOf(String s, String c, boolean ignoreCase)
s
- the string to be inspectedc
- the string to be searched forignoreCase
- if true case is ignored when comparing characterspublic static int indexOfAnyBut(String s, String c)
s
- the string to be inspectedc
- the set of characterspublic static int indexOfAnyBut(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchpublic static int indexOfAnyBut(String s, String c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characterspublic static int indexOfAnyBut(String s, String c, boolean ignoreCase)
s
- the string to be inspectedc
- the set of charactersignoreCase
- if true case is ignored when comparing characterspublic static int indexOfAnyOf(String s, String c)
s
- the string to be inspectedc
- the set of characterspublic static int indexOfAnyOf(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchpublic static int indexOfAnyOf(String s, String c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characterspublic static int indexOfAnyOf(String s, String c, boolean ignoreCase)
s
- the string to be inspectedc
- the set of charactersignoreCase
- if true case is ignored when comparing characterspublic static int indexOfPhrase(String s, String p, int startWord)
s
- the input stringp
- the phrase to be searched forstartWord
- the word number where the search is to start. The
first word has number 0.public static int indexOfPhrase(String s, String p, int startWord, boolean ignoreCase)
s
- the input stringp
- the phrase to be searched forstartWord
- the word number where the search is to start. The
first word has number 0.ignoreCase
- if true case is ignored when comparing characterspublic static int indexOfWord(String s, int wordNum)
s
- the input stringwordNum
- the number of the wordpublic static String insert(String s, String ins, int start)
s
- the input stringins
- the string to be insertedstart
- the starting position for the insertpublic static String insert(String s, String ins, int start, char pad)
s
- the input stringins
- the string to be insertedstart
- the starting position for the insertpad
- the pad characterpublic static boolean isAbbreviationOf(String s, String full, int minLength)
s
is considered an abbreviation of another string
full
if
the string s
is a prefix of string full
and its length is at least
minLength
.s
- the string to testfull
- the full stringminLength
- the minimum lengths
is an abbreviation of string full
.public static boolean isAbbreviationOf(String s, String full, int minLength, boolean ignoreCase)
s
is considered an abbreviation of another string
full
if
the string s
is a prefix of string full
and its length is at least
minLength
.
You can specify that case should be ignored.s
- the string to testfull
- the full stringminLength
- the minimum lengthignoreCase
- if true case is ignored when comparing characterss
is an abbreviation of string full
.public static boolean isAbbreviationOf(String s, String full, boolean ignoreCase)
s
is considered an abbreviation of another string
full
if
the string s
is a prefix of string full
.
You can specify that case should be ignored.s
- the string to testfull
- the full stringignoreCase
- if true case is ignored when comparing characterss
is an abbreviation of string full
.java.lang.string#regionMatches(boolean, int, String, int, int)
public static boolean isDigit(String s)
s
- the input stringCharacter.isDigit(char).
public static boolean isIdentifierIgnorable(String s)
s
- the input stringCharacter.isIdentifierIgnorable(char).
public static boolean isISOControl(String s)
s
- the input stringjava.lang.Character#isISOControls(char).
public static boolean isJavaIdentifier(String s)
s
- the input stringCharacter.isJavaIdentifierStart(char)
,
Character.isJavaIdentifierPart(char).
public static boolean isLetter(String s)
s
- the input stringCharacter.isLetter(char).
public static boolean isLetterOrDigit(String s)
s
- the input stringCharacter.isLetterOrDigit(char).
public static boolean isLike(String s, String pattern)
s
- the string to testpattern
- the pattern stringpublic static boolean isLike(String s, String pattern, int start)
s
- the string to testpattern
- the pattern stringstart
- the starting positionpublic static boolean isLike(String s, String pattern, int start, char wAnySeq, char wAnyChar, boolean ignoreCase)
s
- the string to testpattern
- the pattern stringstart
- the starting positionwAnySeq
- the wildcard character which matches any sequence of characterswAnyChar
- the wildcard character which matches any characterignoreCase
- if true case is ignored when comparing characterspublic static boolean isLike(String s, String pattern, int start, boolean ignoreCase)
s
- the string to testpattern
- the pattern stringstart
- the starting positionignoreCase
- if true case is ignored when comparing characterspublic static boolean isLowerCase(String s)
s
- the input stringjava.lang.Character#isLowercase(char).
public static boolean isSpaceChar(String s)
s
- the input stringCharacter.isSpaceChar(char).
public static boolean isTitleCase(String s)
s
- the input stringCharacter.isTitleCase(char).
public static boolean isUnicodeIdentifier(String s)
s
- the input stringCharacter.isJavaIdentifierStart(char)
,
Character.isJavaIdentifierPart(char)
public static boolean isUpperCase(String s)
s
- the input stringCharacter.isUpperCase(char).
public static boolean isWhitespace(String s)
s
- the input stringCharacter.isWhitespace(char).
public static int lastIndexOf(String s, char c)
s
- the string to be inspectedc
- the string to be searched forjava.lang.string#lastIndexOf(char)
public static int lastIndexOf(String s, char c, int start)
s
- the string to be inspectedc
- the character to be searched forstart
- the starting position for the searchjava.lang.string#lastIndexOf(char, int)
public static int lastIndexOf(String s, char c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the character to be searched forstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing charactersjava.lang.string#lastIndexOf(char, int)
public static int lastIndexOf(String s, String c)
s
- the string to be inspectedc
- the string to be searched forjava.lang.string#lastIndexOf(String)
public static int lastIndexOf(String s, String c, int start)
s
- the string to be inspectedc
- the string to be searched forstart
- the starting position for the searchjava.lang.string#lastIndexOf(String, int)
public static int lastIndexOf(String s, String c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the string to be searched forstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing charactersjava.lang.string#lastIndexOf(String, int)
public static int lastIndexOf(String s, String c, boolean ignoreCase)
s
- the string to be inspectedc
- the string to be searched forignoreCase
- if true case is ignored when comparing characterspublic static int lastIndexOfAnyBut(String s, String c)
s
- the string to be inspectedc
- the set of characterspublic static int lastIndexOfAnyBut(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchpublic static int lastIndexOfAnyBut(String s, String c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characterspublic static int lastIndexOfAnyOf(String s, String c)
s
- the string to be inspectedc
- the set of characterspublic static int lastIndexOfAnyOf(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchpublic static int lastIndexOfAnyOf(String s, String c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characterspublic static String leftJustify(String s, int len)
s
- the input stringlen
- the length of the new stringpublic static String leftJustify(String s, int len, char pad)
s
- the input stringlen
- the length of the new stringpad
- the pad characterpublic static int numWords(String s)
s
- the input stringpublic static int occurrencesOf(String s, String c)
s
- the string to be inspectedc
- the string to search forstart
- the starting position for the searchpublic static int occurrencesOf(String s, String c, int start)
s
- the string to be inspectedc
- the string to search forstart
- the starting position for the searchpublic static int occurrencesOf(String s, String c, int start, boolean ignoreCase)
s
- the string to be inspectedc
- the string to search forstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characterspublic static int occurrencesOf(String s, String c, boolean ignoreCase)
s
- the string to be inspectedc
- the string to search forignoreCase
- if true ignore case when comparing characterspublic static String overlayWith(String s, String o, int start)
s
- the original stringo
- the string to be overlayed over the original stringstart
- the starting position for the overlaypublic static String overlayWith(String s, String o, int start, char pad)
s
- the original stringo
- the string to be overlayed over the original stringstart
- the starting position for the overlaypad
- the padding characterpublic static String remove(String s, int start, int numChars)
s
- the original stringstart
- the starting positionnumChars
- the number of characters to be removedpublic static String removeWords(String s, int startWord, int numWords)
s
- the input stringstartWord
- the number of the first word to be removednumWords
- the number of words to be removed.public static String reverse(String s)
s
- the original stringjava.lang.stringBuffer#reverse()
public static String rightJustify(String s, int len)
s
- the input stringlen
- the length of the new stringpublic static String rightJustify(String s, int len, char pad)
s
- the input stringlen
- the length of the new stringpad
- the pad characterpublic static String[] split(String s)
java.lang.Character#isWhitespace(char)
returns
true
.
(Contributed by Eric Jablow)s
- The string to split into its constituent words.public static String[] split(String s, int limit)
java.lang.Character#isWhitespace(char)
returns
true
.
(Contributed by Eric Jablow)s
- The string to split into its constituent words.limit
- The maximum number of words to return.public static boolean startsWith(String s, String prefix)
s
- the input stringprefix
- the prefixjava.lang.string#startsWith(String)
public static boolean startsWith(String s, String prefix, int start)
s
- the input stringprefix
- the prefixstart
- the starting position for the testjava.lang.string#startsWith(String, int)
public static boolean startsWith(String s, String prefix, int start, boolean ignoreCase)
s
- the input stringprefix
- the prefixstart
- the starting position for the testignoreCase
- if true case is ignored when comparing charactersjava.lang.string#startsWith(String, int)
,
java.lang.string#regionMatches(boolean, int, String, int, int)
public static boolean startsWith(String s, String prefix, boolean ignoreCase)
s
- the input stringprefix
- the prefixignoreCase
- if true case is ignored when comparing charactersjava.lang.string#startsWith(String)
,
java.lang.string#regionMatches(boolean, int, String, int, int)
public static String strip(String s, char c)
s
- the string of which the character should be
stripped offc
- the character to be stripped offpublic static String strip(String s, char c, boolean ignoreCase)
s
- the string of which the character should be
stripped offc
- the character to be stripped offignoreCase
- if true case is ignored when comparing characterspublic static String strip(String s, String c)
s
- the string of which characters should be
stripped offc
- the characters to be stripped offpublic static String strip(String s, String c, boolean ignoreCase)
s
- the string of which characters should be
stripped offc
- the characters to be stripped offignoreCase
- if true case is ignored when comparing characterspublic static String stripBlanks(String s)
s
- the string of which white space is to be stripped offjava.lang.Character#isWhitespace()
public static String stripLeading(String s, char c)
s
- the string of which the leading character should be
stripped offc
- the character to be stripped offpublic static String stripLeading(String s, char c, boolean ignoreCase)
s
- the string of which the leading character should be
stripped offc
- the character to be stripped offignoreCase
- if true case is ignored when comparing characterspublic static String stripLeading(String s, String c)
s
- the string of which the leading characters should be
stripped offc
- the characters to be stripped offpublic static String stripLeading(String s, String c, boolean ignoreCase)
s
- the string of which the leading characters should be
stripped offc
- the characters to be stripped offignoreCase
- if true case is ignored when comparing characterspublic static String stripLeadingBlanks(String s)
s
- the string of which white space is to be stripped offjava.lang.Character#isWhitespace()
public static String stripTrailing(String s, char c)
s
- the string of which trailing characters should be
stripped offc
- the character to be stripped offpublic static String stripTrailing(String s, char c, boolean ignoreCase)
s
- the string of which the trailing character should be
stripped offc
- the character to be stripped offignoreCase
- if true case is ignored when comparing characterspublic static String stripTrailing(String s, String c)
s
- the string of which trailing characters should be
stripped offc
- the characters to be stripped offpublic static String stripTrailing(String s, String c, boolean ignoreCase)
s
- the string of which trailing characters should be
stripped offc
- the characters to be stripped offignoreCase
- if true case is ignored when comparing characterspublic static String stripTrailingBlanks(String s)
s
- the string of which white space is to be stripped offjava.lang.Character#isWhitespace()
public static String substring(String s, int start)
s
- the original stringstart
- the starting positionStringIndexOutOfBoundsException
- if
start
is out of range.java.lang.string#substring(int)
public static String substring(String s, int start, int len)
s
- the original stringstart
- the starting positionlen
- the length of the substringStringIndexOutOfBoundsException
- if
start
is out of range.java.lang.string#substring(int, int)
public static String substring(String s, int start, int len, char pad)
s
- the original stringstart
- the starting positionlen
- the length of the substringpad
- the padding characterStringIndexOutOfBoundsException
- if
start
is out of range or len
is
less than zero.java.lang.string#substring(int, int)
public static String subWords(String s, int startWord, int numWords)
s
- the input stringstartWord
- the word number of the first wordnumWords
- the number of words to be returnedpublic static boolean toBoolean(String s)
s
- the input stringjava.lang.Boolean#valueOf(String).
public static byte toByte(String s) throws NumberFormatException
s
- the input stringNumberFormatException
- if the string cannot be represented
as a byte.java.lang.Byte#valueOf(String).
public static byte toByte(String s, int radix) throws NumberFormatException
s
- the input stringradix
- the radix of the numberNumberFormatException
- if the string cannot be represented
as a byte.java.lang.Byte#valueOf(String, int).
public static double toDouble(String s) throws NumberFormatException
s
- the input stringNumberFormatException
- if the string cannot be represented
as a double.Double.valueOf(String).
public static float toFloat(String s) throws NumberFormatException
s
- the input stringNumberFormatException
- if the string cannot be represented
as a float.Float.valueOf(String).
public static int toInt(String s) throws NumberFormatException
s
- the input stringNumberFormatException
- if the string cannot be represented
as an int.Integer.valueOf(String).
public static int toInt(String s, int radix) throws NumberFormatException
s
- the input stringradix
- the radix of the numberNumberFormatException
- if the string cannot be represented
as an int.Integer.valueOf(String, int).
public static long toLong(String s) throws NumberFormatException
s
- the input stringNumberFormatException
- if the string cannot be represented
as a long.java.lang.Long#valueOf(String).
public static long toLong(String s, int radix) throws NumberFormatException
s
- the input stringradix
- the radix of the numberNumberFormatException
- if the string cannot be represented
as a long.java.lang.Long#valueOf(String, int).
public static String toLowerCase(String s)
s
- the input stringjava.lang.string#toLowerCase()
public static String toLowerCase(String s, Locale locale)
s
- the input stringjava.lang.string#toLowerCase(Locale)
public static short toShort(String s) throws NumberFormatException
s
- the input stringNumberFormatException
- if the string cannot be represented
as a short.java.lang.Short#valueOf(String, int).
public static short toShort(String s, int radix) throws NumberFormatException
s
- the input stringradix
- the radix of the numberNumberFormatException
- if the string cannot be represented
as a short.java.lang.Short#valueOf(String).
public static String toTitleCase(String s)
s
- the input stringCharacter.toTitleCase(char)
public static String toUpperCase(String s)
s
- the input stringjava.lang.string#toUpperCase()
public static String toUpperCase(String s, Locale locale)
s
- the input stringjava.lang.string#toUpperCase(Locale)
public static String translate(String s, String setin, String setout)
s
- the original stringsetin
- the input set of characterssetout
- the output set of characterspublic static String translate(String s, String setin, String setout, char pad)
s
- the original stringsetin
- the input set of characterssetout
- the output set of characterspad
- the pad characterpublic static String translate(String s, String setin, String setout, char pad, boolean ignoreCase)
s
- the original stringsetin
- the input set of characterssetout
- the output set of characterspad
- the pad characterignoreCase
- if true case is ignored when comparing characterspublic static String translate(String s, String setin, String setout, boolean ignoreCase)
s
- the original stringsetin
- the input set of characterssetout
- the output set of charactersignoreCase
- if true case is ignored when comparing characterspublic static String word(String s, int wordNum)
s
- the input stringwordNum
- the number of the word to be returnedpublic static int wordIndexOfPhrase(String s, String p, int startWord)
s
- the input stringp
- the phrase to be searched forstartWord
- the word number where the search is to start. The
first word has number 0.public static int wordIndexOfPhrase(String s, String p, int startWord, boolean ignoreCase)
s
- the input stringp
- the phrase to be searched forstartWord
- the word number where the search is to start. The
first word has number 0.ignoreCase
- if true case is ignored when comparing characterspublic static String wordSpace(String s, int spaces)
s
- the input stringspaces
- the number of blanks between the wordspublic static String xRange(char start, char end)
start
- the starting characterend
- the ending character
|
Colt 1.0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |