| java.lang.Object org.gjt.sp.jedit.TextUtilities
TextUtilities | public class TextUtilities (Code) | | Contains several text manipulation methods.
- Bracket matching
- Word start and end offset calculation
- String comparison
- Converting tabs to spaces and vice versa
- Wrapping text
- String case conversion
author: Slava Pestov version: $Id: TextUtilities.java 9134 2007-03-13 05:30:18Z vanza $ |
Method Summary | |
public 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). | public static int | findWordEnd(String line, int pos, String noWordSep) Locates the end of the word at the specified position. | public static int | findWordEnd(String line, int pos, String noWordSep, boolean joinNonWordChars) Locates the end of the word at the specified position. | public static int | findWordEnd(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean eatWhitespace) Locates the end of the word at the specified position. | public static int | findWordEnd(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean camelCasedWords, boolean eatWhitespace) Locates the end of the word at the specified position. | public static int | findWordStart(String line, int pos, String noWordSep) Locates the start of the word at the specified position. | public static int | findWordStart(String line, int pos, String noWordSep, boolean joinNonWordChars) Locates the start of the word at the specified position. | public static int | findWordStart(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean eatWhitespace) Locates the start of the word at the specified position. | public static int | findWordStart(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean camelCasedWords, boolean eatWhitespace) Locates the start of the word at the specified position. | public static String | format(String text, int maxLineLength, int tabSize) Formats the specified text by merging and breaking lines to the
specified width. | public static char | getComplementaryBracket(char ch, boolean[] direction) Given an opening bracket, return the corresponding closing bracket
and store true in direction[0] . | public static int | getStringCase(String str) Returns if the specified string is all upper case, all lower case,
or title case (first letter upper case, rest lower case). | public static Token | getTokenAtOffset(Token tokens, int offset) Returns the token that contains the specified offset. | public static int | ignoringWhitespaceIndex(String str, int index) Inverse of indexIgnoringWhitespace() . | public static int | indexIgnoringWhitespace(String str, int index) Inverse of ignoringWhitespaceIndex() . | public static void | indexIgnoringWhitespace(String text, int maxLineLength, int tabSize, StringBuffer buf) | public static String | join(Collection c, String delim) Similar to perl's join() method on lists,
but works with all collections. | public static String | spacesToTabs(String in, int tabSize) Converts consecutive spaces to tabs in the specified string. | public static String | tabsToSpaces(String in, int tabSize) Converts tabs to consecutive spaces in the specified string. | public static String | toTitleCase(String str) Converts the specified string to title case, by capitalizing the
first letter. |
BRACKET_MATCH_LIMIT | final public static int BRACKET_MATCH_LIMIT(Code) | | |
LOWER_CASE | final public static int LOWER_CASE(Code) | | |
MIXED | final public static int MIXED(Code) | | |
TITLE_CASE | final public static int TITLE_CASE(Code) | | |
UPPER_CASE | final public static int UPPER_CASE(Code) | | |
findMatchingBracket | public static int findMatchingBracket(JEditBuffer buffer, int line, int offset)(Code) | | 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).
Parameters: buffer - The buffer Parameters: line - The line Parameters: offset - The offset within that line since: jEdit 2.6pre1 |
findWordEnd | public static int findWordEnd(String line, int pos, String noWordSep)(Code) | | Locates the end of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway |
findWordEnd | public static int findWordEnd(String line, int pos, String noWordSep, boolean joinNonWordChars)(Code) | | Locates the end of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway Parameters: joinNonWordChars - Treat consecutive non-alphanumericcharacters as one word since: jEdit 4.1pre2 |
findWordEnd | public static int findWordEnd(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean eatWhitespace)(Code) | | Locates the end of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway Parameters: joinNonWordChars - Treat consecutive non-alphanumericcharacters as one word Parameters: eatWhitespace - Include whitespace at end of word since: jEdit 4.2pre5 |
findWordEnd | public static int findWordEnd(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean camelCasedWords, boolean eatWhitespace)(Code) | | Locates the end of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway Parameters: joinNonWordChars - Treat consecutive non-alphanumericcharacters as one word Parameters: camelCasedWords - Treat "camelCased" parts as words Parameters: eatWhitespace - Include whitespace at end of word since: jEdit 4.3pre10 |
findWordStart | public static int findWordStart(String line, int pos, String noWordSep)(Code) | | Locates the start of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway |
findWordStart | public static int findWordStart(String line, int pos, String noWordSep, boolean joinNonWordChars)(Code) | | Locates the start of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway Parameters: joinNonWordChars - Treat consecutive non-alphanumericcharacters as one word since: jEdit 4.2pre5 |
findWordStart | public static int findWordStart(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean eatWhitespace)(Code) | | Locates the start of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway Parameters: joinNonWordChars - Treat consecutive non-alphanumericcharacters as one word Parameters: eatWhitespace - Include whitespace at start of word since: jEdit 4.1pre2 |
findWordStart | public static int findWordStart(String line, int pos, String noWordSep, boolean joinNonWordChars, boolean camelCasedWords, boolean eatWhitespace)(Code) | | Locates the start of the word at the specified position.
Parameters: line - The text Parameters: pos - The position Parameters: noWordSep - Characters that are non-alphanumeric, butshould be treated as word characters anyway Parameters: joinNonWordChars - Treat consecutive non-alphanumericcharacters as one word Parameters: camelCasedWords - Treat "camelCased" parts as words Parameters: eatWhitespace - Include whitespace at start of word since: jEdit 4.3pre10 |
format | public static String format(String text, int maxLineLength, int tabSize)(Code) | | Formats the specified text by merging and breaking lines to the
specified width.
Parameters: text - The text Parameters: maxLineLength - The maximum line length Parameters: tabSize - The tab size |
getComplementaryBracket | public static char getComplementaryBracket(char ch, boolean[] direction)(Code) | | Given an opening bracket, return the corresponding closing bracket
and store true in direction[0] . Given a closing bracket,
return the corresponding opening bracket and store false in
direction[0] . Otherwise, return \0 .
since: jEdit 4.3pre2 |
getStringCase | public static int getStringCase(String str)(Code) | | Returns if the specified string is all upper case, all lower case,
or title case (first letter upper case, rest lower case).
Parameters: str - The string since: jEdit 4.0pre1 |
getTokenAtOffset | public static Token getTokenAtOffset(Token tokens, int offset)(Code) | | Returns the token that contains the specified offset.
Parameters: tokens - The token list Parameters: offset - The offset since: jEdit 4.0pre3 |
ignoringWhitespaceIndex | public static int ignoringWhitespaceIndex(String str, int index)(Code) | | Inverse of indexIgnoringWhitespace() .
Parameters: str - a string (not an empty string) Parameters: index - The index The index into the string where the number of non-whitespacecharacters that precede the index is count. since: jEdit 4.3pre2 |
indexIgnoringWhitespace | public static int indexIgnoringWhitespace(String str, int index)(Code) | | Inverse of ignoringWhitespaceIndex() .
Parameters: str - a string (not an empty string) Parameters: index - The index The number of non-whitespace characters that precede the index. since: jEdit 4.3pre2 |
indexIgnoringWhitespace | public static void indexIgnoringWhitespace(String text, int maxLineLength, int tabSize, StringBuffer buf)(Code) | | |
join | public static String join(Collection c, String delim)(Code) | | Similar to perl's join() method on lists,
but works with all collections.
Parameters: c - An iterable collection of Objects Parameters: delim - a string to put between each object a joined toString() representation of the collection since: jedit 4.3pre3 |
spacesToTabs | public static String spacesToTabs(String in, int tabSize)(Code) | | Converts consecutive spaces to tabs in the specified string.
Parameters: in - The string Parameters: tabSize - The tab size |
tabsToSpaces | public static String tabsToSpaces(String in, int tabSize)(Code) | | Converts tabs to consecutive spaces in the specified string.
Parameters: in - The string Parameters: tabSize - The tab size |
toTitleCase | public static String toTitleCase(String str)(Code) | | Converts the specified string to title case, by capitalizing the
first letter.
Parameters: str - The string since: jEdit 4.0pre1 |
|
|