Interface ArgumentReader.Mutable

    • Method Detail

      • skipWhitespace

        void skipWhitespace()
        Moves the cursor to the next non-whitespace character. The cursor will not advance if it already refers to a non-whitespace character.
      • parseChar

        char parseChar()
        Reads a character and advances the cursor by one
        Returns:
        The character
      • parseInt

        int parseInt()
              throws ArgumentParseException
        Attempts to read an int from the input starting at the cursor position. The cursor will advance until it finds a non-number and will return an int based on the consumed string.

        Numbers may begin with "-" to indicate a negative number

        When using this in your parser, you should set ValueParser.clientCompletionType() to ClientCompletionTypes.WHOLE_NUMBER to tell the client that the client completion should be an integer.

        Returns:
        The integer
        Throws:
        ArgumentParseException - if the cursor is not at a number character
      • parseDouble

        double parseDouble()
                    throws ArgumentParseException
        Attempts to read a double from the input starting at the cursor position. The cursor will advance until it finds a non-number and will return a double based on the consumed string.

        Numbers may begin with "-" to indicate a negative number, and one period (".") may be present in the string.

        When using this in your parser, you should set ValueParser.clientCompletionType() to ClientCompletionTypes.DECIMAL_NUMBER to tell the client that the client completion should be a floating point number.

        Returns:
        The double
        Throws:
        ArgumentParseException - if the cursor is not at a number character
      • parseFloat

        float parseFloat()
                  throws ArgumentParseException
        Attempts to read a float from the input starting at the cursor position. The cursor will advance until it finds a non-number and will return a float based on the consumed string.

        Numbers may begin with "-" to indicate a negative number, and one period (".") may be present in the string.

        When using this in your parser, you should set ValueParser.clientCompletionType() to ClientCompletionTypes.DECIMAL_NUMBER to tell the client that the client completion should be a floating point number.

        Returns:
        The double
        Throws:
        ArgumentParseException - if the cursor is not at a number character
      • parseUnquotedString

        java.lang.String parseUnquotedString()
                                      throws ArgumentParseException
        Gets the next word in the input from the position of the cursor. This will return a string that contains the characters up to, but excluding, whitespace. The cursor will then be moved to the whitespace after the word.

        As an example, if the input string is eggs bacon spam and the cursor is at position zero (at the beginning), after this operation, the cursor will be at the whitespace between "eggs" and "bacon".

        In general, you will likely wish to use parseString() instead unless you are expecting a double quote mark at the beginning of your string and this is part of the argument you wish to return.

        The following characters will be parsed as part of a valid string without the need for quotation marks.

        • Alphanumeric symbols
        • Underscores (_)
        • Hyphens (-)
        • Periods (.)
        • Plus signs (+)

        If you require other symbols, use parseString() and ensure that users are aware they need to surround their inputs with double quotation marks. Alternatively, consider whether other parse types are suitable (for example, if you are expecting a ResourceKey, use parseResourceKey() or parseResourceKey(String).

        Returns:
        The parsed String
        Throws:
        ArgumentParseException - if a String could not be read
      • parseString

        java.lang.String parseString()
                              throws ArgumentParseException
        Gets a String from the position of the cursor. The parsing of the argument depends on whether a double quote mark is the next character to be consumed.
        • If a double quote is at the beginning of the string , the parser will read characters until a second quotation mark is found and return the string between the two marks. The cursor will then be set to the position after the second mark.
        • If the first character is not a double quote , parseUnquotedString() will parse the string

        If part of the string is quoted, such as "eggs bacon" spam, this method will return eggs bacon on first invocation, then (after running skipWhitespace(), spam on the second.

        Returns:
        The parsed String
        Throws:
        ArgumentParseException - if a String could not be read
      • peekString

        java.lang.String peekString()
                             throws ArgumentParseException
        Returns the next String but does not advance the reader.

        This call will return the same result as parseString(). Calling this multiple times in succession will return the same result each time until another parse* method or setState(ArgumentReader) is called.

        Returns:
        The next string to be read
        Throws:
        ArgumentParseException - if a String could not be read
      • setState

        void setState​(ArgumentReader state)
               throws java.lang.IllegalArgumentException
        Attempts to reset the state of this ArgumentReader.Mutable to the state that the provided ArgumentReader is in. This is generally used with immutable().

        If the provided state does not have the same ArgumentReader.input(), this will throw a IllegalArgumentException

        Parameters:
        state - The state to restore this to
        Throws:
        java.lang.IllegalArgumentException