Class DefaultParser

  • All Implemented Interfaces:
    Parser

    public class DefaultParser
    extends java.lang.Object
    implements Parser
    • Constructor Detail

      • DefaultParser

        public DefaultParser()
    • Method Detail

      • lineCommentDelims

        public DefaultParser lineCommentDelims​(java.lang.String[] lineCommentDelims)
      • escapeChars

        public DefaultParser escapeChars​(char[] chars)
      • eofOnUnclosedQuote

        public DefaultParser eofOnUnclosedQuote​(boolean eofOnUnclosedQuote)
      • 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()
      • setLineCommentDelims

        public void setLineCommentDelims​(java.lang.String[] lineCommentDelims)
      • getLineCommentDelims

        public java.lang.String[] getLineCommentDelims()
      • setEofOnUnclosedQuote

        public void setEofOnUnclosedQuote​(boolean eofOnUnclosedQuote)
      • isEofOnUnclosedQuote

        public boolean isEofOnUnclosedQuote()
      • setEofOnEscapedNewLine

        public void setEofOnEscapedNewLine​(boolean eofOnEscapedNewLine)
      • isEofOnEscapedNewLine

        public boolean isEofOnEscapedNewLine()
      • 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:
        validCommandName in interface Parser
      • validVariableName

        public boolean validVariableName​(java.lang.String name)
        Specified by:
        validVariableName in interface Parser
      • getCommand

        public java.lang.String getCommand​(java.lang.String line)
        Specified by:
        getCommand in interface Parser
      • getVariable

        public java.lang.String getVariable​(java.lang.String line)
        Specified by:
        getVariable in interface Parser
      • 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 of getQuoteChars(), and is not escaped by any of the getEscapeChars(), and returns true from isDelimiterChar(java.lang.CharSequence, int).
        Parameters:
        buffer - The complete command buffer
        pos - 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)
      • isLineCommentStarted

        public boolean isLineCommentStarted​(java.lang.CharSequence buffer,
                                            int pos)
      • isEscapeChar

        public boolean isEscapeChar​(char ch)
        Specified by:
        isEscapeChar in interface Parser
      • 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 in
        pos - 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 in
        pos - 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 the getQuoteChars(), and is not escaped by any of the getEscapeChars(). To perform escaping manually, override isDelimiter(java.lang.CharSequence, int) instead.
        Parameters:
        buffer - the buffer to check in
        pos - the position of the character to check
        Returns:
        true if the character at the specified position in the given buffer is a delimiter.