processing.app.syntax

## Class KeywordMap

- Object
- - KeywordMap

-     public class KeywordMap
      extends Object

  A `KeywordMap` is similar to a hashtable in that it maps keys to values. However, the `keys' are Swing segments. This allows lookups of text substrings without the overhead of creating a new string object.

  This class is used by `CTokenMarker` to map keywords to ids.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `KeywordMap(boolean ignoreCase)` Creates a new `KeywordMap`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(String keyword, byte id, boolean paren)` Adds a key-value mapping.
    `boolean` | `getIgnoreCase()` Returns true if the keyword map is set to be case insensitive, false otherwise.
    `byte` | `lookup(Segment text, int offset, int length, boolean paren)` Looks up a key.
    `static boolean` | `regionMatches(boolean ignoreCase, Segment text, int offset, char[] match)` Checks if a subregion of a `Segment` is equal to a character array.
    `void` | `setIgnoreCase(boolean ignoreCase)` Sets if the keyword map should be case insensitive.

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### KeywordMap

          public KeywordMap(boolean ignoreCase)

      Creates a new `KeywordMap`.
      Parameters:
        `ignoreCase` - True if keys are case insensitive

  - ### Method Detail

    - #### lookup

          public byte lookup(Segment text,
                             int offset,
                             int length,
                             boolean paren)

      Looks up a key.
      Parameters:
        `text` - The text segment
        `offset` - The offset of the substring within the text segment
        `length` - The length of the substring

    - #### regionMatches

          public static boolean regionMatches(boolean ignoreCase,
                                              Segment text,
                                              int offset,
                                              char[] match)

      Checks if a subregion of a `Segment` is equal to a character array.
      Parameters:
        `ignoreCase` - True if case should be ignored, false otherwise
        `text` - The segment
        `offset` - The offset into the segment
        `match` - The character array to match

    - #### add

          public void add(String keyword,
                          byte id,
                          boolean paren)

      Adds a key-value mapping.
      Parameters:
        `keyword` - The key
        `id` - The value

    - #### getIgnoreCase

          public boolean getIgnoreCase()

      Returns true if the keyword map is set to be case insensitive, false otherwise.

    - #### setIgnoreCase

          public void setIgnoreCase(boolean ignoreCase)

      Sets if the keyword map should be case insensitive.
      Parameters:
        `ignoreCase` - True if the keyword map should be case insensitive, false otherwise