java.lang.Object
com.maroontress.clione.impl.Case

public final class Case extends Object
The mapping of one or more characters to a tokenizer.

Note that the Case instance is an immutable object.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    The function that that takes a character and returns a tokenizer associated with the character.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the unmodifiable set of characters that this case maps.
    Returns the tokenizer that this case maps characters to.
    newMapper(Case... cases)
    Returns a new mapping function that takes a character and returns a tokenizer associated with the character with the specified cases.
    static Case
    of(char c, Tokenizer tokenizer)
    Returns a new case that starts with the specified character and has the specified tokenizer.
    static Case
    of(char c, Tokenizer otherwise, Case... cases)
    Returns a new case that starts with the specified character and that one of the specified cases may follow.
    static Case
    of(char c, TokenType otherwise, Case... cases)
    Returns a new case that starts with the specified character and that one of the specified cases may follow.
    static Case
    of(Set<Character> set, Tokenizer tokenizer)
    Returns a new case that maps the specified character set to the specified tokenizer.
    static Case
    of(Set<Character> set, TokenType otherwise, Case... cases)
    Returns a new case that starts with one of characters in the specified set and that one of the specified cases may follow it.

    Methods inherited from class java.lang.Object

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

    • getCharSet

      public Set<Character> getCharSet()
      Returns the unmodifiable set of characters that this case maps.
      Returns:
      The unmodifiable set of characters.
    • getTokenizer

      public Tokenizer getTokenizer()
      Returns the tokenizer that this case maps characters to.
      Returns:
      The tokenizer.
    • of

      public static Case of(char c, Tokenizer tokenizer)
      Returns a new case that starts with the specified character and has the specified tokenizer.
      Parameters:
      c - The character that the case starts with.
      tokenizer - The tokenizer associated with the case.
      Returns:
      The new case.
    • of

      public static Case of(Set<Character> set, Tokenizer tokenizer)
      Returns a new case that maps the specified character set to the specified tokenizer.
      Parameters:
      set - The set of characters to map
      tokenizer - The tokenizer to map characters to.
      Returns:
      The new case.
    • of

      public static Case of(char c, TokenType otherwise, Case... cases)
      Returns a new case that starts with the specified character and that one of the specified cases may follow.
      Parameters:
      c - The character that the case starts with.
      otherwise - The token type that the tokenizer returns when none of the specified cases follows the character c.
      cases - The cases that may follow the character c.
      Returns:
      The new case.
    • of

      public static Case of(char c, Tokenizer otherwise, Case... cases)
      Returns a new case that starts with the specified character and that one of the specified cases may follow.
      Parameters:
      c - The character that the case starts with.
      otherwise - The tokenizer returns when none of the specified cases follows the character c.
      cases - The cases that may follow the character c.
      Returns:
      The new case.
    • of

      public static Case of(Set<Character> set, TokenType otherwise, Case... cases)
      Returns a new case that starts with one of characters in the specified set and that one of the specified cases may follow it.
      Parameters:
      set - The set of characters, one of which the case starts with.
      otherwise - The token type that the tokenizer returns when none of the specified cases follows the one of the characters.
      cases - The cases that may follow one of the characters.
      Returns:
      The new case.
    • newMapper

      public static Case.Mapper newMapper(Case... cases)
      Returns a new mapping function that takes a character and returns a tokenizer associated with the character with the specified cases.
      Parameters:
      cases - The cases.
      Returns:
      The new map.