Package org.jline.reader.impl
Class DefaultParser
- java.lang.Object
-
- org.jline.reader.impl.DefaultParser
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDefaultParser.ArgumentListThe result of a delimited buffer.static classDefaultParser.Bracketprivate classDefaultParser.BracketChecker-
Nested classes/interfaces inherited from interface org.jline.reader.Parser
Parser.ParseContext
-
-
Field Summary
Fields Modifier and Type Field Description private char[]closingBracketsprivate intcommandGroupprivate booleaneofOnEscapedNewLineprivate booleaneofOnUnclosedQuoteprivate char[]escapeCharsprivate char[]openingBracketsprivate char[]quoteCharsprivate java.lang.StringregexCommandprivate java.lang.StringregexVariable-
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 DefaultParsercommandGroup(int commandGroup)DefaultParsereofOnEscapedNewLine(boolean eofOnEscapedNewLine)DefaultParsereofOnUnclosedBracket(DefaultParser.Bracket... brackets)DefaultParsereofOnUnclosedQuote(boolean eofOnUnclosedQuote)DefaultParserescapeChars(char[] chars)java.lang.StringgetCommand(java.lang.String line)char[]getEscapeChars()char[]getQuoteChars()java.lang.StringgetVariable(java.lang.String line)booleanisDelimiter(java.lang.CharSequence buffer, int pos)Returns true if the specified character is a whitespace parameter.booleanisDelimiterChar(java.lang.CharSequence buffer, int pos)Returns true if the character at the specified position if a delimiter.booleanisEofOnEscapedNewLine()booleanisEofOnUnclosedQuote()booleanisEscapeChar(char ch)booleanisEscapeChar(java.lang.CharSequence buffer, int pos)Check if this character is a valid escape char (i.e.booleanisEscaped(java.lang.CharSequence buffer, int pos)Check if a character is escaped (i.e.booleanisQuoteChar(java.lang.CharSequence buffer, int pos)booleanisQuoted(java.lang.CharSequence buffer, int pos)private booleanisRawEscapeChar(char key)private booleanisRawQuoteChar(char key)ParsedLineparse(java.lang.String line, int cursor, Parser.ParseContext context)DefaultParserquoteChars(char[] chars)DefaultParserregexCommand(java.lang.String regexCommand)DefaultParserregexVariable(java.lang.String regexVariable)voidsetCommandGroup(int commandGroup)voidsetEofOnEscapedNewLine(boolean eofOnEscapedNewLine)voidsetEofOnUnclosedBracket(DefaultParser.Bracket... brackets)voidsetEofOnUnclosedQuote(boolean eofOnUnclosedQuote)voidsetEscapeChars(char[] chars)voidsetQuoteChars(char[] chars)voidsetRegexCommand(java.lang.String regexCommand)voidsetRegexVariable(java.lang.String regexVariable)booleanvalidCommandName(java.lang.String name)booleanvalidVariableName(java.lang.String name)
-
-
-
Field Detail
-
quoteChars
private char[] quoteChars
-
escapeChars
private char[] escapeChars
-
eofOnUnclosedQuote
private boolean eofOnUnclosedQuote
-
eofOnEscapedNewLine
private boolean eofOnEscapedNewLine
-
openingBrackets
private char[] openingBrackets
-
closingBrackets
private char[] closingBrackets
-
regexVariable
private java.lang.String regexVariable
-
regexCommand
private java.lang.String regexCommand
-
commandGroup
private int commandGroup
-
-
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(java.lang.String regexVariable)
-
regexCommand
public DefaultParser regexCommand(java.lang.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(java.lang.String regexVariable)
-
setRegexCommand
public void setRegexCommand(java.lang.String regexCommand)
-
setCommandGroup
public void setCommandGroup(int commandGroup)
-
validCommandName
public boolean validCommandName(java.lang.String name)
- Specified by:
validCommandNamein interfaceParser
-
validVariableName
public boolean validVariableName(java.lang.String name)
- Specified by:
validVariableNamein interfaceParser
-
getCommand
public java.lang.String getCommand(java.lang.String line)
- Specified by:
getCommandin interfaceParser
-
getVariable
public java.lang.String getVariable(java.lang.String line)
- Specified by:
getVariablein interfaceParser
-
parse
public ParsedLine parse(java.lang.String line, int cursor, Parser.ParseContext context)
-
isDelimiter
public boolean isDelimiter(java.lang.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(java.lang.CharSequence buffer, int pos)
-
isQuoteChar
public boolean isQuoteChar(java.lang.CharSequence buffer, int pos)
-
isEscapeChar
public boolean isEscapeChar(char ch)
- Specified by:
isEscapeCharin interfaceParser
-
isEscapeChar
public boolean isEscapeChar(java.lang.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(java.lang.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(java.lang.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.
-
isRawEscapeChar
private boolean isRawEscapeChar(char key)
-
isRawQuoteChar
private boolean isRawQuoteChar(char key)
-
-