Module jEdit

Class KeywordMap

java.lang.Object
org.gjt.sp.jedit.syntax.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.
Version:
$Id: KeywordMap.java 25244 2020-04-15 15:14:49Z kpouer $
Author:
Slava Pestov, Mike Dillon
  • Constructor Summary

    Constructors
    Constructor
    Description
    KeywordMap(boolean ignoreCase)
    Creates a new KeywordMap.
    KeywordMap(boolean ignoreCase, int mapLength)
    Creates a new KeywordMap.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(char[] keyword, byte id)
    Adds a key-value mapping.
    void
    add(String keyword, byte id)
    Adds a key-value mapping.
    void
    Adds the content of another keyword map to this one.
    boolean
    Returns true if the keyword map is set to be case insensitive, false otherwise.
    Returns an array containing all keywords in this keyword map.
    Returns all non-alphanumeric characters that appear in the keywords of this keyword map.
    protected int
    getSegmentMapKey(Segment s, int off, int len)
     
    byte
    lookup(Segment text, int offset, int length)
    Looks up a key.
    void
    setIgnoreCase(boolean ignoreCase)
    Sets if the keyword map should be case insensitive.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KeywordMap

      public KeywordMap(boolean ignoreCase)
      Creates a new KeywordMap.
      Parameters:
      ignoreCase - True if keys are case insensitive
    • KeywordMap

      public KeywordMap(boolean ignoreCase, int mapLength)
      Creates a new KeywordMap.
      Parameters:
      ignoreCase - True if the keys are case insensitive
      mapLength - The number of `buckets' to create. A value of 52 will give good performance for most maps.
  • Method Details

    • lookup

      public byte lookup(Segment text, int offset, int length)
      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
    • add

      public void add(String keyword, byte id)
      Adds a key-value mapping.
      Parameters:
      keyword - The key
      id - The value
    • add

      public void add(char[] keyword, byte id)
      Adds a key-value mapping.
      Parameters:
      keyword - The key
      id - The value
      Since:
      jEdit 4.2pre3
    • getNonAlphaNumericChars

      public String getNonAlphaNumericChars()
      Returns all non-alphanumeric characters that appear in the keywords of this keyword map.
      Since:
      jEdit 4.0pre3
    • getKeywords

      public String[] getKeywords()
      Returns an array containing all keywords in this keyword map.
      Since:
      jEdit 4.0pre3
    • 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
    • add

      public void add(KeywordMap map)
      Adds the content of another keyword map to this one.
      Since:
      jEdit 4.2pre3
    • getSegmentMapKey

      protected int getSegmentMapKey(Segment s, int off, int len)