|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ix.util.Strings
public final class Strings
A class containing useful static string methods.
Method Summary | |
---|---|
static java.lang.String |
afterFirst(java.lang.String separator,
java.lang.String s)
Returns the substring that begins directly after the first occurrence of the separator. |
static java.lang.String |
afterLast(java.lang.String separator,
java.lang.String s)
Returns the substring starting directly after the last occurrence of the separator. |
static java.lang.String |
beforeFirst(java.lang.String separator,
java.lang.String s)
Returns the substring that ends directly before the first occurrence of the separator. |
static java.lang.String |
beforeLast(java.lang.String separator,
java.lang.String s)
Returns the substring that ends directly before the last occurrence of the separator. |
static java.util.List<java.lang.String> |
breakAt(java.lang.String separator,
java.lang.String s)
Returns a list of the substrings delimited by the given separator. |
static java.util.List<java.lang.String> |
breakAtAny(java.lang.String separatorChars,
java.lang.String s)
Returns a list of substrings, breaking the string at every occurrence of a separator charater. |
static java.lang.String[] |
breakAtFirst(java.lang.String separator,
java.lang.String s)
breakAtFirst takes a string containing fields separated by a (string) delimiter and returns a two-element string array containing the substring before the first occurrence of the separator and the substring after. |
static java.lang.String[] |
breakAtLast(java.lang.String separator,
java.lang.String s)
breakAtLast takes a string containing fields separated by a (string) delimiter and returns a two-element string array containing the substring before the last occurrence of the separator and the substring after. |
static java.util.List<java.lang.String> |
breakIntoLines(java.lang.String text)
Returns a List of the lines in a string. |
static java.lang.String |
capitalize(java.lang.String s)
Returns a copy of the string in which the first character is in upper case and the rest of the string is left as it was. |
static java.lang.String |
conjunction(java.util.Collection items)
Returns a conjunction formed from the elements of a collection. |
static java.lang.String |
dashNameToFullJavaName(java.lang.String name)
Like dashNameToJavaName but also allows package names, separated by dots, to prefix the class name. |
static java.lang.String |
dashNameToJavaName(java.lang.String name)
Converts a name in which words are separate by dashes into one that uses Java-style capitalisation instead. |
static java.lang.String |
disjunction(java.util.Collection items)
Returns a disjunction formed from the elements of a collection. |
static java.lang.String |
firstLine(java.lang.String s)
Returns the first line of a string. |
static java.lang.String |
foldLongLine(java.lang.String text)
Replaces some spaces with line separators to make a long string more readable in contexts where it would have been displayed as a single line. |
static java.lang.String |
foldLongLine(java.lang.String text,
int maxLen,
java.lang.String prefix)
Replaces some spaces with line separators to make a long string more readable in contexts where it would have been displayed as a single line. |
static java.lang.String[] |
foldToArray(java.lang.String text)
Makes a long string more readable by breaking it into lines. |
static java.lang.String |
fullJavaNameToDashName(java.lang.String name)
Like javaNameToDashName but also allows package names, separated by dots, to prefix the class name. |
static java.lang.String |
indefinite(java.lang.String noun)
Returns a string prefixed by "an " or "a " depending on whether or not it begins with an English vowel. |
static int |
indexOfAny(java.lang.String chars,
int start,
java.lang.String s)
Returns the index of the first occurrence of any of the specified characters, or -1 if none are found. |
static int |
indexOfAny(java.lang.String chars,
java.lang.String s)
Returns the index of the first occurrence of any of the specified characters, or -1 if none are found. |
static boolean |
isAllLowerCase(java.lang.String s)
Determines whether there are no upper-case characters in a string. |
static boolean |
isVowel(char c)
Returns true if the character is an English vowel (a, e, i, o, or u) and false if it is not. |
static java.lang.String |
javaNameToDashName(java.lang.String name)
Converts a name that shows word boundaries using Java-style capitalization to a name in which words are (almost) all lower case and separated by dashes. |
static java.lang.String |
joinLines(java.util.List lines)
Returns a String formed by appending a list of strings with a line-separator between adjacent elements. |
static java.lang.String |
joinLines(java.lang.String[] lines)
Returns a String formed by appending an array of strings with a line-separator between adjacent elements. |
static java.lang.String |
joinWith(java.lang.String separator,
java.util.List substrings)
Returns a String formed by appending a List of strings with a separator between adjacent elements. |
static java.lang.String |
joinWith(java.lang.String separator,
java.lang.String[] substrings)
Returns a String formed by appending an array of strings with a separator between adjacent elements. |
static java.lang.String |
quote(java.lang.String text)
Puts double quotes around a string. |
static java.lang.String |
repeat(int count,
java.lang.String s)
Returns a String made by appending a specified string count times. |
static java.lang.String |
replace(java.lang.String from,
java.lang.String to,
java.lang.String source)
Returns a string formed by replacing every occurrence of from with to in source. |
static java.lang.String |
replaceChars(java.lang.String from,
java.lang.String to,
java.lang.String source)
Returns a copy of source in any character that appears in from has been replaced by the the corresponding char in to. |
static java.lang.String[] |
toArray(java.util.Collection strings)
Converts a collection of Strings to a new String array of the same size. |
static java.lang.String |
uncapitalize(java.lang.String s)
Returns a copy of the string in which the first character is in lower case and the rest of the string is left as it was. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String[] toArray(java.util.Collection strings)
public static int indexOfAny(java.lang.String chars, java.lang.String s)
chars
- the characters to look fors
- the string to look inpublic static int indexOfAny(java.lang.String chars, int start, java.lang.String s)
chars
- the characters to look forstart
- index to start lookings
- the string to look inpublic static java.lang.String[] breakAtFirst(java.lang.String separator, java.lang.String s)
separator
- the delimiters
- the string that may contain itpublic static java.lang.String[] breakAtLast(java.lang.String separator, java.lang.String s)
separator
- the delimiters
- the string that may contain itpublic static java.util.List<java.lang.String> breakAt(java.lang.String separator, java.lang.String s)
separator
- the delimiters
- the string that may contain itpublic static java.util.List<java.lang.String> breakAtAny(java.lang.String separatorChars, java.lang.String s)
separatorChars
- the separatorss
- the string to break into partsbreakAt(String, String)
public static java.lang.String joinWith(java.lang.String separator, java.util.List substrings)
separator
- the delimiter that will separate substringssubstrings
- a list of the Strings to joinpublic static java.lang.String joinWith(java.lang.String separator, java.lang.String[] substrings)
separator
- the delimiter that will separate substringssubstrings
- an array of the Strings to joinpublic static java.lang.String joinLines(java.util.List lines)
lines
- a list of the Strings to joinpublic static java.lang.String joinLines(java.lang.String[] lines)
lines
- an array of the Strings to joinpublic static java.lang.String beforeFirst(java.lang.String separator, java.lang.String s)
separator
- the delimiters
- the string that may contain itpublic static java.lang.String afterFirst(java.lang.String separator, java.lang.String s)
separator
- the delimiters
- the string that may contain itpublic static java.lang.String beforeLast(java.lang.String separator, java.lang.String s)
separator
- the delimiters
- the string that may contain itpublic static java.lang.String afterLast(java.lang.String separator, java.lang.String s)
separator
- the delimiters
- the string that may contain itpublic static java.lang.String firstLine(java.lang.String s)
public static java.util.List<java.lang.String> breakIntoLines(java.lang.String text)
public static java.lang.String foldLongLine(java.lang.String text)
public static java.lang.String foldLongLine(java.lang.String text, int maxLen, java.lang.String prefix)
The prefix, if not null, is put at the front of every resulting line except the first.
public static java.lang.String[] foldToArray(java.lang.String text)
foldLongLine(String)
that
returns an array of lines rather than a string containing
containing newline sequences.
public static java.lang.String replace(java.lang.String from, java.lang.String to, java.lang.String source)
from
- the text to replaceto
- the text to replace it withsource
- the text in which to do the replacing
public static java.lang.String replaceChars(java.lang.String from, java.lang.String to, java.lang.String source)
from
- chars to replaceto
- the chars to replace them withsource
- the text in which to do the replacing
public static java.lang.String quote(java.lang.String text)
public static boolean isVowel(char c)
public static java.lang.String indefinite(java.lang.String noun)
isVowel(char)
public static java.lang.String disjunction(java.util.Collection items)
public static java.lang.String conjunction(java.util.Collection items)
public static boolean isAllLowerCase(java.lang.String s)
public static java.lang.String capitalize(java.lang.String s)
public static java.lang.String uncapitalize(java.lang.String s)
public static java.lang.String repeat(int count, java.lang.String s)
public static java.lang.String dashNameToJavaName(java.lang.String name)
javaNameToDashName(String)
,
dashNameToFullJavaName(String)
public static java.lang.String dashNameToFullJavaName(java.lang.String name)
The names of inner classes (which contain dollar-signs) are handled by converting the sequence of class names.
dashNameToJavaName(String)
,
fullJavaNameToDashName(String)
public static java.lang.String javaNameToDashName(java.lang.String name)
JavaNameWordIterator
,
dashNameToJavaName(String)
,
fullJavaNameToDashName(String)
public static java.lang.String fullJavaNameToDashName(java.lang.String name)
The names of inner classes (which contain dollar-signs) are handled by converting the sequence of class names.
javaNameToDashName(String)
,
dashNameToFullJavaName(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |