Class Parser
java.lang.Object
org.aesh.readline.util.Parser
String/Parser util methods
- Author:
- Ståle W. Pedersen invalid input: '<'stale.pedersen@jboss.org>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charstatic final charstatic final charstatic final charstatic final Stringstatic final char -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanarrayContains(int[] source, int[] target) static intarrayIndexOf(int[] source, int[] target) static intarrayIndexOf(int[] source, int sourceOffset, int sourceCount, int[] target, int targetOffset, int targetCount, int fromIndex) static booleancontainsNonEscapedDollar(String buffer) static booleancontainsNonEscapedSpace(String buffer) static booleanstatic booleandoesStringContainOpenQuote(String text, int flags) Check if a string contain open quotes.static booleanstatic booleanstatic intfindAllOccurrences(String word, String pattern) static StringfindCurrentWordFromCursor(String text, int cursor) Return the word "connected" to cursor, the word ends at cursor position.static StringSearch backwards for a non-escaped space and only return work containing non-escaped spacestatic StringfindFirstWord(String buffer) If string contain space, return the text before the first space.static booleanfindIfWordEndWithSpace(String word) static intfind number of spaces in the given word. escaped spaces are not countedstatic StringfindStartsWith(List<String> completionList) Return the biggest common startsWith stringstatic StringfindStartsWithOperation(List<? extends CompleteOperation> coList) If there is any common start string in the completion list, return itstatic StringfindStartsWithTerminalString(List<TerminalString> completionList) Return the biggest common startsWith stringstatic StringfindWordClosestToCursor(String text, int cursor) static StringformatDisplayCompactListTerminalString(List<TerminalString> displayList, int termWidth) Format output to columns with flexible sizes and no redundant space between themstatic StringformatDisplayList(String[] displayList, int termHeight, int termWidth) Format completions so that they look similar to GNU Readlinestatic StringformatDisplayList(List<String> displayList, int termHeight, int termWidth) Format completions so that they look similar to GNU Readlinestatic StringformatDisplayListTerminalString(List<TerminalString> displayList, int termHeight, int termWidth) Format completions so that they look similar to GNU Readlinestatic StringfromCodePoints(int[] input) static booleanisTrimmedArrayEmpty(int[] input) static Stringstatic StringsplitBySizeKeepWords(String words, int size) static StringstripAwayAnsiCodes(String text) static voidstatic Stringstatic Stringstatic int[]static StringSimilar to String.trim(), but do not remove spaces that are escapedstatic StringtrimInFront(String buffer) Only trim space in front of the wordstatic StringtrimOptionName(String word) remove leading dashes from word
-
Field Details
-
SPACE
- See Also:
-
SPACE_CHAR
public static final char SPACE_CHAR- See Also:
-
BACK_SLASH
public static final char BACK_SLASH- See Also:
-
SINGLE_QUOTE
public static final char SINGLE_QUOTE- See Also:
-
DOUBLE_QUOTE
public static final char DOUBLE_QUOTE- See Also:
-
DOLLAR
public static final char DOLLAR- See Also:
-
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
formatDisplayList
-
formatDisplayList
-
formatDisplayListTerminalString
public static String formatDisplayListTerminalString(List<TerminalString> displayList, int termHeight, int termWidth) Format completions so that they look similar to GNU Readline- Parameters:
displayList- to formattermHeight- max heighttermWidth- max width- Returns:
- formatted string to be outputted
-
formatDisplayCompactListTerminalString
public static String formatDisplayCompactListTerminalString(List<TerminalString> displayList, int termWidth) Format output to columns with flexible sizes and no redundant space between them- Parameters:
displayList- to formattermWidth- max width- Returns:
- formatted string to be outputted
-
padRight
-
padLeft
-
splitBySizeKeepWords
-
trimOptionName
-
findIfWordEndWithSpace
-
findStartsWithOperation
If there is any common start string in the completion list, return it- Parameters:
coList- completion list- Returns:
- common start string
-
findStartsWith
-
findStartsWithTerminalString
Return the biggest common startsWith string- Parameters:
completionList- list to compare- Returns:
- biggest common startsWith string
-
findWordClosestToCursor
-
findCurrentWordFromCursor
-
findEscapedSpaceWordCloseToEnd
-
doesStringContainOpenQuote
Check if a string contain open quotes. Escaped quotes does not count.- Parameters:
text- textflags- flags,1to ignore double quotes,2to ignore single quotes. Other values will check for both.- Returns:
- true if it contains open quotes, else false
-
doesStringContainOpenQuote
-
doWordContainOnlyEscapedSpace
-
doWordContainEscapedSpace
-
findNumberOfSpacesInWord
find number of spaces in the given word. escaped spaces are not counted- Parameters:
word- to check- Returns:
- number of spaces
-
findAllOccurrences
-
switchEscapedSpacesToSpacesInList
-
switchEscapedSpacesToSpacesInTerminalStringList
-
switchSpacesToEscapedSpacesInWord
-
switchEscapedSpacesToSpacesInWord
-
trim
-
trimInFront
-
findFirstWord
-
containsNonEscapedDollar
-
containsNonEscapedSpace
-
stripAwayAnsiCodes
-
toCodePoints
-
fromCodePoints
-
isTrimmedArrayEmpty
public static boolean isTrimmedArrayEmpty(int[] input) -
arrayIndexOf
public static int arrayIndexOf(int[] source, int[] target) -
arrayIndexOf
public static int arrayIndexOf(int[] source, int sourceOffset, int sourceCount, int[] target, int targetOffset, int targetCount, int fromIndex) -
arrayContains
public static boolean arrayContains(int[] source, int[] target)
-