|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectViolinStrings.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
Constructor Summary | |
protected |
Strings()
|
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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Strings()
Method Detail |
public static boolean equals(char c1, char c2, boolean ignoreCase)
c1
- first characterc2
- second characterignoreCase
- if true case is ignored when comparing characters
string
public static boolean equals(String s1, String s2, boolean ignoreCase)
s1
- first strings2
- second stringignoreCase
- if true case is ignored when comparing characters
string
public static int compare(String s1, String s2)
s1
- the first strings2
- second string
s1
is lexicographically less than s2
,
and a value greater than
zero if s1
is lexicographically greater than s2
.string
public static boolean startsWith(String s, String prefix, boolean ignoreCase)
s
- the input stringprefix
- the prefixignoreCase
- if true case is ignored when comparing characters
string
,
string
public static boolean startsWith(String s, String prefix)
s
- the input stringprefix
- the prefix
string
public static boolean startsWith(String s, String prefix, int start)
s
- the input stringprefix
- the prefixstart
- the starting position for the test
string
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 characters
string
,
string
public static boolean endsWith(String s, String suffix, boolean ignoreCase)
s
- the input stringsuffix
- the suffixignoreCase
- if true case is ignored when comparing characters
string
,
string
public static boolean endsWith(String s, String suffix)
s
- the input stringsuffix
- the suffix
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 search
string
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 characters
string
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 characters
public static int indexOf(String s, String c)
s
- the string to be inspectedc
- the string to be searched for
string
public static int indexOf(String s, char c)
s
- the string to be inspectedc
- the character to be searched for
string
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 characters
string
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 characters
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 search
string
public static int indexOfAnyOf(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the search
public 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 characters
public 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 characters
public static int indexOfAnyOf(String s, String c)
s
- the string to be inspectedc
- the set of characters
public 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 characters
public 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 characters
public static int indexOfAnyBut(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the search
public static int indexOfAnyBut(String s, String c)
s
- the string to be inspectedc
- the set of characters
public 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 characters
public 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 characters
public 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 search
public static int occurrencesOf(String s, String c)
s
- the string to be inspectedc
- the string to search for
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 characters
string
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 characters
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 search
string
public static int lastIndexOf(String s, String c)
s
- the string to be inspectedc
- the string to be searched for
string
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 characters
string
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 search
string
public static int lastIndexOf(String s, char c)
s
- the string to be inspectedc
- the string to be searched for
string
public 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 characters
public static int lastIndexOfAnyBut(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the search
public static int lastIndexOfAnyBut(String s, String c)
s
- the string to be inspectedc
- the set of characters
public 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 characters
public static int lastIndexOfAnyOf(String s, String c, int start)
s
- the string to be inspectedc
- the set of charactersstart
- the starting position for the search
public static int lastIndexOfAnyOf(String s, String c)
s
- the string to be inspectedc
- the set of characters
public 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 characters
public static String stripLeading(String s, String c)
s
- the string of which the leading characters should be
stripped offc
- the characters to be stripped off
public 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 characters
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 off
public static String stripLeadingBlanks(String s)
s
- the string of which white space is to be stripped off
Character.isWhitespace(char)
public 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 characters
public static String stripTrailing(String s, String c)
s
- the string of which trailing characters should be
stripped offc
- the characters to be stripped off
public 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 characters
public static String stripTrailing(String s, char c)
s
- the string of which trailing characters should be
stripped offc
- the character to be stripped off
public static String stripTrailingBlanks(String s)
s
- the string of which white space is to be stripped off
Character.isWhitespace(char)
public 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 characters
public static String strip(String s, String c)
s
- the string of which characters should be
stripped offc
- the characters to be stripped off
public 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 characters
public static String strip(String s, char c)
s
- the string of which the character should be
stripped offc
- the character to be stripped off
public static String stripBlanks(String s)
s
- the string of which white space is to be stripped off
Character.isWhitespace(char)
public static String center(String s, int len, char pad)
s
- the original stringlen
- the length of the new stringpad
- the pad character
public static String center(String s, int len)
s
- the original stringlen
- the length of the new string
public 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 characters
public 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 characters
public 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 changes
public 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 search
public 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 characters
public static String change(String s, String oldp, String newp)
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement string
public 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 characters
public 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 changes
public 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 characters
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 search
public static String change(String s, char oldc, char newc)
s
- the input stringoldc
- the pattern to be replacednewc
- the replacement string
string
public static String copies(String s, int nCopies)
s
- the input stringnCopies
- the number of copies
stringBuffer
public 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 character
public static String insert(String s, String ins, int start)
s
- the input stringins
- the string to be insertedstart
- the starting position for the insert
public static String leftJustify(String s, int len, char pad)
s
- the input stringlen
- the length of the new stringpad
- the pad character
public static String leftJustify(String s, int len)
s
- the input stringlen
- the length of the new string
public static String rightJustify(String s, int len, char pad)
s
- the input stringlen
- the length of the new stringpad
- the pad character
public static String rightJustify(String s, int len)
s
- the input stringlen
- the length of the new string
public static String toLowerCase(String s)
s
- the input string
string
public static String toLowerCase(String s, Locale locale)
s
- the input string
string
public static String toUpperCase(String s)
s
- the input string
string
public static String toUpperCase(String s, Locale locale)
s
- the input string
string
public static String toTitleCase(String s)
s
- the input string
Character.toTitleCase(char)
public 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 character
public 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 overlay
public static String remove(String s, int start, int numChars)
s
- the original stringstart
- the starting positionnumChars
- the number of characters to be removed
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 character
StringIndexOutOfBoundsException
- if
start
is out of range or len
is
less than zero.string
public static String substring(String s, int start, int len)
s
- the original stringstart
- the starting positionlen
- the length of the substring
StringIndexOutOfBoundsException
- if
start
is out of range.string
public static String substring(String s, int start)
s
- the original stringstart
- the starting position
StringIndexOutOfBoundsException
- if
start
is out of range.string
public static String reverse(String s)
s
- the original string
stringBuffer
public 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 characters
public 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 character
public 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 characters
public static String translate(String s, String setin, String setout)
s
- the original stringsetin
- the input set of characterssetout
- the output set of characters
public static String xRange(char start, char end)
start
- the starting characterend
- the ending character
public static boolean contains(String s, String search, boolean ignoreCase)
s
- the input stringsearch
- the search stringignoreCase
- if true case is ignored when comparing characters
string
public static boolean contains(String s, String search)
s
- the original stringsearch
- the search string
string
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 characters
s
is an abbreviation of string full
.public 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 length
s
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 characters
s
is an abbreviation of string full
.string
public 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 characters
public 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 characters
public static boolean isLike(String s, String pattern, int start)
s
- the string to testpattern
- the pattern stringstart
- the starting position
public static boolean isLike(String s, String pattern)
s
- the string to testpattern
- the pattern string
public static int indexOfWord(String s, int wordNum)
s
- the input stringwordNum
- the number of the word
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 characters
public 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 numWords(String s)
s
- the input string
public 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 wordSpace(String s, int spaces)
s
- the input stringspaces
- the number of blanks between the words
public static String word(String s, int wordNum)
s
- the input stringwordNum
- the number of the word to be returned
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 characters
public 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 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 returned
public 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 toBoolean(String s)
s
- the input string
Boolean.valueOf(String).
public static byte toByte(String s) throws NumberFormatException
s
- the input string
NumberFormatException
- if the string cannot be represented
as a byte.Byte.valueOf(String).
public static byte toByte(String s, int radix) throws NumberFormatException
s
- the input stringradix
- the radix of the number
NumberFormatException
- if the string cannot be represented
as a byte.Byte.valueOf(String, int).
public static short toShort(String s, int radix) throws NumberFormatException
s
- the input stringradix
- the radix of the number
NumberFormatException
- if the string cannot be represented
as a short.Short.valueOf(String).
public static short toShort(String s) throws NumberFormatException
s
- the input string
NumberFormatException
- if the string cannot be represented
as a short.Short.valueOf(String, int).
public static int toInt(String s) throws NumberFormatException
s
- the input string
NumberFormatException
- 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 number
NumberFormatException
- if the string cannot be represented
as an int.Integer.valueOf(String, int).
public static long toLong(String s) throws NumberFormatException
s
- the input string
NumberFormatException
- if the string cannot be represented
as a long.Long.valueOf(String).
public static long toLong(String s, int radix) throws NumberFormatException
s
- the input stringradix
- the radix of the number
NumberFormatException
- if the string cannot be represented
as a long.Long.valueOf(String, int).
public static float toFloat(String s) throws NumberFormatException
s
- the input string
NumberFormatException
- if the string cannot be represented
as a float.Float.valueOf(String).
public static double toDouble(String s) throws NumberFormatException
s
- the input string
NumberFormatException
- if the string cannot be represented
as a double.Double.valueOf(String).
public static boolean isDigit(String s)
s
- the input string
Character.isDigit(char).
public static boolean isIdentifierIgnorable(String s)
s
- the input string
Character.isIdentifierIgnorable(char).
public static boolean isISOControl(String s)
s
- the input string
Character.isISOControl(char).
public static boolean isJavaIdentifier(String s)
s
- the input string
Character.isJavaIdentifierStart(char)
,
Character.isJavaIdentifierPart(char).
public static boolean isLetter(String s)
s
- the input string
Character.isLetter(char).
public static boolean isLetterOrDigit(String s)
s
- the input string
Character.isLetterOrDigit(char).
public static boolean isLowerCase(String s)
s
- the input string
Character.isLowerCase(char).
public static boolean isSpaceChar(String s)
s
- the input string
Character.isSpaceChar(char).
public static boolean isTitleCase(String s)
s
- the input string
Character.isTitleCase(char).
public static boolean isUnicodeIdentifier(String s)
s
- the input string
Character.isJavaIdentifierStart(char)
,
Character.isJavaIdentifierPart(char)
public static boolean isUpperCase(String s)
s
- the input string
Character.isUpperCase(char).
public static boolean isWhitespace(String s)
s
- the input string
Character.isWhitespace(char).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |