|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.prorefactor.refactor.util.Strings
public class Strings
Helper class to provide String manipulation functions not available in standard JDK. Copied from org.eclipse.jdt.internal.corext.util.Strings. I'm not sure why that class isn't a core Eclipse class, would have been handy there. Note that some Joanju methods have been added to the top of the class.
Constructor Summary | |
---|---|
Strings()
|
Method Summary | |
---|---|
static java.lang.String |
changeIndent(java.lang.String code,
int codeIndentLevel,
int tabWidth,
java.lang.String newIndent,
java.lang.String lineDelim)
Change the indent of, possible muti-line, code range. |
static java.lang.String |
changeIndent(java.lang.String text,
java.lang.String newIndent,
java.lang.String lineDelim)
Joanju variation - change the indent on a block of code. |
static int |
computeIndent(java.lang.String line,
int tabWidth)
Returns the indent of the given string. |
static java.lang.String |
concatenate(java.lang.String[] lines,
java.lang.String delimiter)
Concatenate the given strings into one strings using the passed line delimiter as a delimiter. |
static boolean |
containsOnlyWhitespaces(java.lang.String s)
Returns true if the given string only consists of
white spaces according to Java. |
static java.lang.String[] |
convertIntoLines(java.lang.String input)
Converts the given string into an array of lines. |
static boolean |
equals(java.lang.String s,
char[] c)
|
static java.lang.String |
getIndentString(java.lang.String line)
Joanju variation - does nothing with tabwidth. |
static java.lang.String |
getIndentString(java.lang.String line,
int tabWidth)
|
static boolean |
isIndentChar(char ch)
Indent char is a space char but not a line delimiters. |
static boolean |
isLineDelimiterChar(char ch)
Line delimiter chars are '\n' and '\r'. |
static boolean |
isLowerCase(char ch)
tests if a char is lower case. |
static java.lang.String |
removeNewLine(java.lang.String message)
|
static java.lang.String[] |
removeTrailingEmptyLines(java.lang.String[] sourceLines)
|
static java.lang.String |
trimIndent(java.lang.String line,
int indentsToRemove,
int tabWidth)
Removes the given number of idents from the line. |
static void |
trimIndentation(java.lang.String[] lines,
int tabWidth)
Removes the common number of indents from all lines. |
static void |
trimIndentation(java.lang.String[] lines,
int tabWidth,
boolean considerFirstLine)
Removes the common number of indents from all lines. |
static java.lang.String |
trimIndents(java.lang.String s,
int tabWidth)
Removes all leading indents from the given line. |
static java.lang.String |
trimLeadingTabsAndSpaces(java.lang.String line)
Removes leading tabs and spaces from the given string. |
static java.lang.String |
trimTrailingTabsAndSpaces(java.lang.String line)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Strings()
Method Detail |
---|
public static java.lang.String changeIndent(java.lang.String text, java.lang.String newIndent, java.lang.String lineDelim)
public static java.lang.String getIndentString(java.lang.String line)
public static boolean isIndentChar(char ch)
== Character.isWhitespace(ch) && ch != '\n' && ch != '\r'
public static boolean isLowerCase(char ch)
public static boolean isLineDelimiterChar(char ch)
public static java.lang.String removeNewLine(java.lang.String message)
public static java.lang.String[] convertIntoLines(java.lang.String input)
null
if the input string can't be converted in an array of lines.public static boolean containsOnlyWhitespaces(java.lang.String s)
true
if the given string only consists of
white spaces according to Java. If the string is empty, true
is returned.
true
if the string only consists of white
spaces; otherwise false
is returnedCharacter.isWhitespace(char)
public static java.lang.String trimLeadingTabsAndSpaces(java.lang.String line)
public static java.lang.String trimTrailingTabsAndSpaces(java.lang.String line)
public static int computeIndent(java.lang.String line, int tabWidth)
line
- the text linetabWidth
- the width of the '\t' character.public static java.lang.String trimIndent(java.lang.String line, int indentsToRemove, int tabWidth)
indentsToRemove <= 0
the line is returned.
public static java.lang.String trimIndents(java.lang.String s, int tabWidth)
public static void trimIndentation(java.lang.String[] lines, int tabWidth)
public static void trimIndentation(java.lang.String[] lines, int tabWidth, boolean considerFirstLine)
considerFirstLine
is false the first line will be ignored.
public static java.lang.String getIndentString(java.lang.String line, int tabWidth)
public static java.lang.String[] removeTrailingEmptyLines(java.lang.String[] sourceLines)
public static java.lang.String changeIndent(java.lang.String code, int codeIndentLevel, int tabWidth, java.lang.String newIndent, java.lang.String lineDelim)
public static java.lang.String concatenate(java.lang.String[] lines, java.lang.String delimiter)
public static boolean equals(java.lang.String s, char[] c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |