| java.lang.Object rcm.util.Str
Str | abstract public class Str (Code) | | String utility routines.
|
Method Summary | |
public static String | abbreviate(String s, int max) Abbreviate a string. | public static String | abbreviateLines(String s, int maxLines, String message) Abbreviate a multi-line string.
Parameters: s - String to abbreviate Parameters: maxLines - Max number of lines in returned string; must be at least 3 Parameters: message - Message to replace removed lines with; should end with\n, but may be multiple lines. | public static String | after(String s, String pat) Split string around a substring match and return suffix.
Parameters: s - String to split Parameters: pat - Substring to search for in s Suffix of s starting just after the first occurrenceof pat. | public static String | before(String s, String pat) Split string around a substring match and return prefix.
Parameters: s - String to split Parameters: pat - Substring to search for in s Prefix of s ending just before the first occurrenceof pat. | public static String | compressWhitespace(String s) Compress whitespace. | static int | countLines(String s) | public static boolean | endsWithIgnoreCase(String s, String suffix) Like String.endsWith, but case-insensitive. | public static String | escape(String subject, char escapeChar, String metachars) Escapes metacharacters in a string. | public static String | escape(String subject, String chars, char escapeChar, String metachars) Escapes characters in a string.
Parameters: subject - String in which metacharacters are to be escaped Parameters: chars - Characters that need to be escaped (e.g. | public static int | indexOfAnyChar(String subject, String chars) Find first occurence of any of a set of characters. | public static int | indexOfAnyChar(String subject, String chars, int start) Find first occurence of any of a set of characters, starting
at a specified index. | public static boolean | isWhitespace(String s) Test if string contains only whitespace. | public static String | join(String[] list, String sep) Concatenate an array of strings.
Parameters: list - Array of strings to concatenate Parameters: sep - Separator to insert between each string string consisting of list[0] + sep + list[1] + sep + ... | public static String | longestCommonPrefix(String s, String t) Find longest common prefix of two strings. | public static String | longestCommonPrefixIgnoreCase(String s, String t) Find longest common prefix of two strings, ignoring case. | public static int | longestCommonPrefixLength(String s, String t) | public static int | longestCommonPrefixLengthIgnoreCase(String s, String t) | public static String | longestCommonSuffix(String s, String t) Find longest common suffix of two strings. | public static String | longestCommonSuffixIgnoreCase(String s, String t) Find longest common suffix of two strings, ignoring case. | public static int | longestCommonSuffixLength(String s, String t) | public static int | longestCommonSuffixLengthIgnoreCase(String s, String t) | static int | nthLine(String s, int n) | public static Number | parseNumber(String s) | public static String | repeat(String s, int n) Generate a string by concatenating n copies of another string. | public static String | replace(String subject, String original, String replacement) Replace all occurences of a string. | public static String | reverse(String s) Reverse a string. | public static boolean | startsWithIgnoreCase(String s, String prefix) Like String.startsWith, but case-insensitive. | public static String | unescape(String subject, char escapeChar, String metachars, String chars, boolean keepUntranslatedEscapes) Translate escape sequences (e.g. | public static String | untabify(String s, int tabsize) Expands tabs to spaces. |
abbreviate | public static String abbreviate(String s, int max)(Code) | | Abbreviate a string.
Parameters: s - String to abbreviate Parameters: max - Maximum length of returned string; must be at least 5 |
abbreviateLines | public static String abbreviateLines(String s, int maxLines, String message)(Code) | | Abbreviate a multi-line string.
Parameters: s - String to abbreviate Parameters: maxLines - Max number of lines in returned string; must be at least 3 Parameters: message - Message to replace removed lines with; should end with\n, but may be multiple lines. Occurrences of %d are replaced withthe number of lines removed. |
after | public static String after(String s, String pat)(Code) | | Split string around a substring match and return suffix.
Parameters: s - String to split Parameters: pat - Substring to search for in s Suffix of s starting just after the first occurrenceof pat. If pat is not found in s, returns "". |
before | public static String before(String s, String pat)(Code) | | Split string around a substring match and return prefix.
Parameters: s - String to split Parameters: pat - Substring to search for in s Prefix of s ending just before the first occurrenceof pat. If pat is not found in s, returns s itself. |
compressWhitespace | public static String compressWhitespace(String s)(Code) | | Compress whitespace.
Parameters: s - String to compress string with leading and trailing whitespace removed, andinternal runs of whitespace replaced by a single space character |
endsWithIgnoreCase | public static boolean endsWithIgnoreCase(String s, String suffix)(Code) | | Like String.endsWith, but case-insensitive.
|
escape | public static String escape(String subject, char escapeChar, String metachars)(Code) | | Escapes metacharacters in a string.
Parameters: subject - String in which metacharacters are to be escaped Parameters: escapeChar - the escape character (e.g., \) Parameters: metachars - the metacharacters that should be escaped subject with escapeChar inserted before every character found in metachars |
escape | public static String escape(String subject, String chars, char escapeChar, String metachars)(Code) | | Escapes characters in a string.
Parameters: subject - String in which metacharacters are to be escaped Parameters: chars - Characters that need to be escaped (e.g. "\b\t\r\n\\") Parameters: escapeChar - the escape character (e.g., '\\') Parameters: metachars - escape code letters corresponding to each letter in chars (e.g. "btrn\\")Must have metachars.length () == chars.length(). subject where every occurence of c in chars is replacedby escapeChar followed the character corresponding to c in metachars. |
indexOfAnyChar | public static int indexOfAnyChar(String subject, String chars)(Code) | | Find first occurence of any of a set of characters.
Parameters: subject - String in which to search Parameters: chars - Characters to search for index of first occurence in subject of a character from chars,or -1 if no match. |
indexOfAnyChar | public static int indexOfAnyChar(String subject, String chars, int start)(Code) | | Find first occurence of any of a set of characters, starting
at a specified index.
Parameters: subject - String in which to search Parameters: chars - Characters to search for Parameters: start - Starting offset to search from index of first occurence (after start) in subject of a character from chars,or -1 if no match. |
isWhitespace | public static boolean isWhitespace(String s)(Code) | | Test if string contains only whitespace.
Parameters: s - String to test true iff all characters in s satisfy Character.isWhitespace().If s is empty, returns true. |
join | public static String join(String[] list, String sep)(Code) | | Concatenate an array of strings.
Parameters: list - Array of strings to concatenate Parameters: sep - Separator to insert between each string string consisting of list[0] + sep + list[1] + sep + ... + sep + list[list.length-1] |
longestCommonPrefix | public static String longestCommonPrefix(String s, String t)(Code) | | Find longest common prefix of two strings.
|
longestCommonPrefixIgnoreCase | public static String longestCommonPrefixIgnoreCase(String s, String t)(Code) | | Find longest common prefix of two strings, ignoring case.
|
longestCommonPrefixLength | public static int longestCommonPrefixLength(String s, String t)(Code) | | |
longestCommonPrefixLengthIgnoreCase | public static int longestCommonPrefixLengthIgnoreCase(String s, String t)(Code) | | |
longestCommonSuffix | public static String longestCommonSuffix(String s, String t)(Code) | | Find longest common suffix of two strings.
|
longestCommonSuffixIgnoreCase | public static String longestCommonSuffixIgnoreCase(String s, String t)(Code) | | Find longest common suffix of two strings, ignoring case.
|
longestCommonSuffixLength | public static int longestCommonSuffixLength(String s, String t)(Code) | | |
longestCommonSuffixLengthIgnoreCase | public static int longestCommonSuffixLengthIgnoreCase(String s, String t)(Code) | | |
repeat | public static String repeat(String s, int n)(Code) | | Generate a string by concatenating n copies of another string.
Parameters: s - String to repeat Parameters: n - number of times to repeat s s concatenated with itself n times |
replace | public static String replace(String subject, String original, String replacement)(Code) | | Replace all occurences of a string.
Parameters: subject - String in which to search Parameters: original - String to search for in subject Parameters: replacement - String to substitute subject with all occurences of original replaced by replacement |
reverse | public static String reverse(String s)(Code) | | Reverse a string.
Parameters: s - String to reverse string containing characters of s in reverse order |
startsWithIgnoreCase | public static boolean startsWithIgnoreCase(String s, String prefix)(Code) | | Like String.startsWith, but case-insensitive.
|
unescape | public static String unescape(String subject, char escapeChar, String metachars, String chars, boolean keepUntranslatedEscapes)(Code) | | Translate escape sequences (e.g. \r, \n) to characters.
Parameters: subject - String in which metacharacters are to be escaped Parameters: escapeChar - the escape character (e.g., \) Parameters: metachars - letters representing escape codes (typically "btrn\\") Parameters: chars - characters corresponding to metachars (typically "\b\t\r\n\\").Must have chars.length () == metachars.length(). Parameters: keepUntranslatedEscapes - Controls behavior on unknown escape sequences(see below). subject where every escapeChar followed by c in metacharsis replaced by the character corresponding to c in chars. If an escapesequence is untranslatable (because escapeChar is followed by some character cnot in metachars), then the escapeChar is kept if keepUntranslatedEscapes is true,otherwise the escapeChar is deleted. (The character c is always kept.) |
untabify | public static String untabify(String s, int tabsize)(Code) | | Expands tabs to spaces.
|
|
|