- java.lang.Object
-
- org.jline.reader.impl.DefaultParser
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DefaultParser.ArgumentList
The result of a delimited buffer.static class
DefaultParser.Bracket
-
Nested classes/interfaces inherited from interface org.jline.reader.Parser
Parser.ParseContext
-
-
Field Summary
-
Fields inherited from interface org.jline.reader.Parser
REGEX_COMMAND, REGEX_VARIABLE
-
-
Constructor Summary
Constructors Constructor Description DefaultParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultParser
commandGroup(int commandGroup)
DefaultParser
eofOnEscapedNewLine(boolean eofOnEscapedNewLine)
DefaultParser
eofOnUnclosedBracket(DefaultParser.Bracket... brackets)
DefaultParser
eofOnUnclosedQuote(boolean eofOnUnclosedQuote)
DefaultParser
escapeChars(char[] chars)
String
getCommand(String line)
char[]
getEscapeChars()
char[]
getQuoteChars()
String
getVariable(String line)
boolean
isDelimiter(CharSequence buffer, int pos)
Returns true if the specified character is a whitespace parameter.boolean
isDelimiterChar(CharSequence buffer, int pos)
Returns true if the character at the specified position if a delimiter.boolean
isEofOnEscapedNewLine()
boolean
isEofOnUnclosedQuote()
boolean
isEscapeChar(char ch)
boolean
isEscapeChar(CharSequence buffer, int pos)
Check if this character is a valid escape char (i.e.boolean
isEscaped(CharSequence buffer, int pos)
Check if a character is escaped (i.e.boolean
isQuoteChar(CharSequence buffer, int pos)
boolean
isQuoted(CharSequence buffer, int pos)
ParsedLine
parse(String line, int cursor, Parser.ParseContext context)
DefaultParser
quoteChars(char[] chars)
DefaultParser
regexCommand(String regexCommand)
DefaultParser
regexVariable(String regexVariable)
void
setCommandGroup(int commandGroup)
void
setEofOnEscapedNewLine(boolean eofOnEscapedNewLine)
void
setEofOnUnclosedBracket(DefaultParser.Bracket... brackets)
void
setEofOnUnclosedQuote(boolean eofOnUnclosedQuote)
void
setEscapeChars(char[] chars)
void
setQuoteChars(char[] chars)
void
setRegexCommand(String regexCommand)
void
setRegexVariable(String regexVariable)
boolean
validCommandName(String name)
boolean
validVariableName(String name)
-
-
-
Method Detail
-
quoteChars
public DefaultParser quoteChars(char[] chars)
-
escapeChars
public DefaultParser escapeChars(char[] chars)
-
eofOnUnclosedQuote
public DefaultParser eofOnUnclosedQuote(boolean eofOnUnclosedQuote)
-
eofOnUnclosedBracket
public DefaultParser eofOnUnclosedBracket(DefaultParser.Bracket... brackets)
-
eofOnEscapedNewLine
public DefaultParser eofOnEscapedNewLine(boolean eofOnEscapedNewLine)
-
regexVariable
public DefaultParser regexVariable(String regexVariable)
-
regexCommand
public DefaultParser regexCommand(String regexCommand)
-
commandGroup
public DefaultParser commandGroup(int commandGroup)
-
setQuoteChars
public void setQuoteChars(char[] chars)
-
getQuoteChars
public char[] getQuoteChars()
-
setEscapeChars
public void setEscapeChars(char[] chars)
-
getEscapeChars
public char[] getEscapeChars()
-
setEofOnUnclosedQuote
public void setEofOnUnclosedQuote(boolean eofOnUnclosedQuote)
-
isEofOnUnclosedQuote
public boolean isEofOnUnclosedQuote()
-
setEofOnEscapedNewLine
public void setEofOnEscapedNewLine(boolean eofOnEscapedNewLine)
-
isEofOnEscapedNewLine
public boolean isEofOnEscapedNewLine()
-
setEofOnUnclosedBracket
public void setEofOnUnclosedBracket(DefaultParser.Bracket... brackets)
-
setRegexVariable
public void setRegexVariable(String regexVariable)
-
setRegexCommand
public void setRegexCommand(String regexCommand)
-
setCommandGroup
public void setCommandGroup(int commandGroup)
-
validCommandName
public boolean validCommandName(String name)
- Specified by:
validCommandName
in interfaceParser
-
validVariableName
public boolean validVariableName(String name)
- Specified by:
validVariableName
in interfaceParser
-
getCommand
public String getCommand(String line)
- Specified by:
getCommand
in interfaceParser
-
getVariable
public String getVariable(String line)
- Specified by:
getVariable
in interfaceParser
-
parse
public ParsedLine parse(String line, int cursor, Parser.ParseContext context)
-
isDelimiter
public boolean isDelimiter(CharSequence buffer, int pos)
Returns true if the specified character is a whitespace parameter. Check to ensure that the character is not escaped by any ofgetQuoteChars()
, and is not escaped by any of thegetEscapeChars()
, and returns true fromisDelimiterChar(java.lang.CharSequence, int)
.- Parameters:
buffer
- The complete command bufferpos
- The index of the character in the buffer- Returns:
- True if the character should be a delimiter
-
isQuoted
public boolean isQuoted(CharSequence buffer, int pos)
-
isQuoteChar
public boolean isQuoteChar(CharSequence buffer, int pos)
-
isEscapeChar
public boolean isEscapeChar(char ch)
- Specified by:
isEscapeChar
in interfaceParser
-
isEscapeChar
public boolean isEscapeChar(CharSequence buffer, int pos)
Check if this character is a valid escape char (i.e. one that has not been escaped)- Parameters:
buffer
- the buffer to check inpos
- the position of the character to check- Returns:
- true if the character at the specified position in the given buffer is an escape character and the character immediately preceding it is not an escape character.
-
isEscaped
public boolean isEscaped(CharSequence buffer, int pos)
Check if a character is escaped (i.e. if the previous character is an escape)- Parameters:
buffer
- the buffer to check inpos
- the position of the character to check- Returns:
- true if the character at the specified position in the given buffer is an escape character and the character immediately preceding it is an escape character.
-
isDelimiterChar
public boolean isDelimiterChar(CharSequence buffer, int pos)
Returns true if the character at the specified position if a delimiter. This method will only be called if the character is not enclosed in any of thegetQuoteChars()
, and is not escaped by any of thegetEscapeChars()
. To perform escaping manually, overrideisDelimiter(java.lang.CharSequence, int)
instead.- Parameters:
buffer
- the buffer to check inpos
- the position of the character to check- Returns:
- true if the character at the specified position in the given buffer is a delimiter.
-
-