org.springframework.shell.core

## Class Tokenizer

- java.lang.Object
- - org.springframework.shell.core.Tokenizer

-     public class Tokenizer
      extends Object

  Converts a particular buffer into a tokenized structure.

  Properly treats double quotes (") as option delimiters.

  Expects option names to be preceded by a double dash. We call this an "option marker".

  Treats spaces as the default option tokenizer.

  Any token without an option marker is considered the default. The default is returned in the Map as an element with an empty string key (""). There can only be a single default.

  Since:
    1.1

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Tokenizer(String text)`
    `Tokenizer(String text, boolean allowUnbalancedLastQuotedValue)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `escape(String value)` Apply delimiter escaping to the given string, using the actual delimiter that was used for the last value.
    `char` | `getLastValueDelimiter()` Return the delimiter (space or quotes) that was (or is being) used for the last value.
    `int` | `getLastValueStartOffset()` Return the offset at which the last value seen started (NOT including any delimiter).
    `Map<String,String>` | `getTokens()`
    `boolean` | `lastValueIsComplete()` Return true if we know for sure that the last value has been typed in full.
    `boolean` | `openingQuotesHaveNotBeenClosed()` Return whether the last value was meant to be enclosed in quotes, but the closing quote has not been typed yet.
    `void` | `tokenize()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Tokenizer

          public Tokenizer(String text)

    - #### Tokenizer

          public Tokenizer(String text,
                   boolean allowUnbalancedLastQuotedValue)

  - ### Method Detail

    - #### tokenize

          public void tokenize()

    - #### getTokens

          public Map<String,String> getTokens()

    - #### getLastValueStartOffset

          public int getLastValueStartOffset()

      Return the offset at which the last value seen started (NOT including any delimiter).

    - #### getLastValueDelimiter

          public char getLastValueDelimiter()

      Return the delimiter (space or quotes) that was (or is being) used for the last value.

    - #### openingQuotesHaveNotBeenClosed

          public boolean openingQuotesHaveNotBeenClosed()

      Return whether the last value was meant to be enclosed in quotes, but the closing quote has not been typed yet.

    - #### lastValueIsComplete

          public boolean lastValueIsComplete()

      Return true if we know for sure that the last value has been typed in full.

    - #### escape

          public String escape(String value)

      Apply delimiter escaping to the given string, using the actual delimiter that was used for the last value.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`