public class TextUtilities
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
| static int | BRACKET_MATCH_LIMIT | 
| static int | LOWER_CASE | 
| static int | MIXED | 
| static int | SYMBOL | 
| static int | TITLE_CASE | 
| static int | UPPER_CASE | 
| static int | WHITESPACE | 
| static int | WORD_CHAR | 
| Constructor and Description | 
|---|
| TextUtilities() | 
| Modifier and Type | Method and Description | 
|---|---|
| static java.lang.String | escapeText(java.lang.String text)Escapes a given string for use in a java.util.regex pattern. | 
| static int | findMatchingBracket(JEditBuffer buffer,
                   int line,
                   int offset)Returns the offset of the bracket matching the one at the
 specified offset of the buffer, or -1 if the bracket is
 unmatched (or if the character is not a bracket). | 
| static int | findWordEnd(java.lang.CharSequence line,
           int pos,
           java.lang.String noWordSep)Locates the end of the word at the specified position. | 
| static int | findWordEnd(java.lang.CharSequence line,
           int pos,
           java.lang.String noWordSep,
           boolean joinNonWordChars,
           boolean camelCasedWords,
           boolean eatWhitespace)Locates the end of the word at the specified position. | 
| static int | findWordEnd(java.lang.String line,
           int pos,
           java.lang.String noWordSep)Locates the end of the word at the specified position. | 
| static int | findWordEnd(java.lang.String line,
           int pos,
           java.lang.String noWordSep,
           boolean joinNonWordChars)Locates the end of the word at the specified position. | 
| static int | findWordEnd(java.lang.String line,
           int pos,
           java.lang.String noWordSep,
           boolean joinNonWordChars,
           boolean eatWhitespace)Locates the end of the word at the specified position. | 
| static int | findWordEnd(java.lang.String line,
           int pos,
           java.lang.String noWordSep,
           boolean joinNonWordChars,
           boolean camelCasedWords,
           boolean eatWhitespace)Locates the end of the word at the specified position. | 
| static int | findWordStart(java.lang.CharSequence line,
             int pos,
             java.lang.String noWordSep)Locates the start of the word at the specified position. | 
| static int | findWordStart(java.lang.CharSequence line,
             int pos,
             java.lang.String noWordSep,
             boolean joinNonWordChars,
             boolean camelCasedWords,
             boolean eatWhitespace)Locates the start of the word at the specified position. | 
| static int | findWordStart(java.lang.CharSequence line,
             int pos,
             java.lang.String noWordSep,
             boolean joinNonWordChars,
             boolean camelCasedWords,
             boolean eatWhitespace,
             boolean eatOnlyAfterWord)Locates the start of the word at the specified position. | 
| static int | findWordStart(java.lang.String line,
             int pos,
             java.lang.String noWordSep)Locates the start of the word at the specified position. | 
| static int | findWordStart(java.lang.String line,
             int pos,
             java.lang.String noWordSep,
             boolean joinNonWordChars)Locates the start of the word at the specified position. | 
| static int | findWordStart(java.lang.String line,
             int pos,
             java.lang.String noWordSep,
             boolean joinNonWordChars,
             boolean eatWhitespace)Locates the start of the word at the specified position. | 
| static int | findWordStart(java.lang.String line,
             int pos,
             java.lang.String noWordSep,
             boolean joinNonWordChars,
             boolean camelCasedWords,
             boolean eatWhitespace)Locates the start of the word at the specified position. | 
| static java.lang.String | format(java.lang.String text,
      int maxLineLength,
      int tabSize)Formats the specified text by merging and breaking lines to the
 specified width. | 
| static int | getCharType(char ch,
           java.lang.String noWordSep)Returns the type of the char. | 
| static char | getComplementaryBracket(char ch,
                       boolean[] direction)Given an opening bracket, return the corresponding closing bracket
 and store true in  direction[0]. | 
| static int | getStringCase(java.lang.CharSequence str)Returns if the specified string is all upper case, all lower case,
 or title case (first letter upper case, rest lower case). | 
| static int | getStringCase(java.lang.String str)Returns if the specified string is all upper case, all lower case,
 or title case (first letter upper case, rest lower case). | 
| static Token | getTokenAtOffset(Token tokens,
                int offset)Returns the token that contains the specified offset. | 
| static int | ignoringWhitespaceIndex(java.lang.String str,
                       int index)Inverse of  indexIgnoringWhitespace(). | 
| static int | indexIgnoringWhitespace(java.lang.String str,
                       int index)Inverse of  ignoringWhitespaceIndex(). | 
| static void | indexIgnoringWhitespace(java.lang.String text,
                       int maxLineLength,
                       int tabSize,
                       java.lang.StringBuffer buf) | 
| static java.lang.String | join(java.util.Collection<?> c,
    java.lang.String delim)Similar to perl's join() method on lists,
    but works with all collections. | 
| static java.lang.String | spacesToTabs(java.lang.String in,
            int tabSize)Converts consecutive spaces to tabs in the specified string. | 
| static java.lang.String | tabsToSpaces(java.lang.String in,
            int tabSize)Converts tabs to consecutive spaces in the specified string. | 
| static java.lang.String | toTitleCase(java.lang.String str)Converts the specified string to title case, by capitalizing the
 first letter. | 
public static final int BRACKET_MATCH_LIMIT
public static final int WHITESPACE
public static final int WORD_CHAR
public static final int SYMBOL
public static final int MIXED
public static final int LOWER_CASE
public static final int UPPER_CASE
public static final int TITLE_CASE
public static Token getTokenAtOffset(Token tokens, int offset)
tokens - The token listoffset - The offsetpublic static char getComplementaryBracket(char ch,
                                           boolean[] direction)
direction[0]. Given a closing bracket,
 return the corresponding opening bracket and store false in
 direction[0]. Otherwise, return \0.public static int findMatchingBracket(JEditBuffer buffer, int line, int offset)
buffer - The bufferline - The lineoffset - The offset within that linepublic static java.lang.String join(java.util.Collection<?> c,
                                    java.lang.String delim)
c - An iterable collection of Objectsdelim - a string to put between each objectpublic static int findWordStart(java.lang.String line,
                                int pos,
                                java.lang.String noWordSep)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywaypublic static int findWordStart(java.lang.CharSequence line,
                                int pos,
                                java.lang.String noWordSep)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywaypublic static int findWordStart(java.lang.String line,
                                int pos,
                                java.lang.String noWordSep,
                                boolean joinNonWordChars)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordpublic static int findWordStart(java.lang.String line,
                                int pos,
                                java.lang.String noWordSep,
                                boolean joinNonWordChars,
                                boolean eatWhitespace)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordeatWhitespace - Include whitespace at start of wordpublic static int findWordStart(java.lang.String line,
                                int pos,
                                java.lang.String noWordSep,
                                boolean joinNonWordChars,
                                boolean camelCasedWords,
                                boolean eatWhitespace)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordcamelCasedWords - Treat "camelCased" parts as wordseatWhitespace - Include whitespace at start of wordpublic static int findWordStart(java.lang.CharSequence line,
                                int pos,
                                java.lang.String noWordSep,
                                boolean joinNonWordChars,
                                boolean camelCasedWords,
                                boolean eatWhitespace)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordcamelCasedWords - Treat "camelCased" parts as wordseatWhitespace - Include whitespace at start of wordpublic static int findWordStart(java.lang.CharSequence line,
                                int pos,
                                java.lang.String noWordSep,
                                boolean joinNonWordChars,
                                boolean camelCasedWords,
                                boolean eatWhitespace,
                                boolean eatOnlyAfterWord)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordcamelCasedWords - Treat "camelCased" parts as wordseatWhitespace - Include whitespace at start of wordeatOnlyAfterWord - Eat only whitespace after a word,
 in effect this finds actual word starts even if eatingpublic static int findWordEnd(java.lang.String line,
                              int pos,
                              java.lang.String noWordSep)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywaypublic static int findWordEnd(java.lang.CharSequence line,
                              int pos,
                              java.lang.String noWordSep)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywaypublic static int findWordEnd(java.lang.String line,
                              int pos,
                              java.lang.String noWordSep,
                              boolean joinNonWordChars)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordpublic static int findWordEnd(java.lang.String line,
                              int pos,
                              java.lang.String noWordSep,
                              boolean joinNonWordChars,
                              boolean eatWhitespace)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordeatWhitespace - Include whitespace at end of wordpublic static int findWordEnd(java.lang.String line,
                              int pos,
                              java.lang.String noWordSep,
                              boolean joinNonWordChars,
                              boolean camelCasedWords,
                              boolean eatWhitespace)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordcamelCasedWords - Treat "camelCased" parts as wordseatWhitespace - Include whitespace at end of wordpublic static int findWordEnd(java.lang.CharSequence line,
                              int pos,
                              java.lang.String noWordSep,
                              boolean joinNonWordChars,
                              boolean camelCasedWords,
                              boolean eatWhitespace)
line - The textpos - The positionnoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anywayjoinNonWordChars - Treat consecutive non-alphanumeric
 characters as one wordcamelCasedWords - Treat "camelCased" parts as wordseatWhitespace - Include whitespace at end of wordpublic static int getCharType(char ch,
                              java.lang.String noWordSep)
ch - the characternoWordSep - Characters that are non-alphanumeric, but
 should be treated as word characters anyway, it must not be nullWHITESPACE,
 WORD_CHAR, SYMBOLpublic static java.lang.String spacesToTabs(java.lang.String in,
                                            int tabSize)
in - The stringtabSize - The tab sizepublic static java.lang.String tabsToSpaces(java.lang.String in,
                                            int tabSize)
in - The stringtabSize - The tab sizepublic static java.lang.String format(java.lang.String text,
                                      int maxLineLength,
                                      int tabSize)
text - The textmaxLineLength - The maximum line lengthtabSize - The tab sizepublic static int indexIgnoringWhitespace(java.lang.String str,
                                          int index)
ignoringWhitespaceIndex().str - a string (not an empty string)index - The indexpublic static int ignoringWhitespaceIndex(java.lang.String str,
                                          int index)
indexIgnoringWhitespace().str - a string (not an empty string)index - The indexpublic static int getStringCase(java.lang.CharSequence str)
str - The stringpublic static int getStringCase(java.lang.String str)
str - The stringpublic static java.lang.String toTitleCase(java.lang.String str)
str - The stringpublic static java.lang.String escapeText(java.lang.String text)
public static void indexIgnoringWhitespace(java.lang.String text,
                                           int maxLineLength,
                                           int tabSize,
                                           java.lang.StringBuffer buf)