Class Lex

java.lang.Object
com.globalmentor.lex.Lex

public class Lex extends Object
Constants and utilities for lexical analysis.
Author:
Garret Wilson
  • Constructor Details

    • Lex

      public Lex()
  • Method Details

    • serialize

      public static String serialize(Identifier identifier)
      Returns a serialized form of an identifier. Usually the identifier is an Enum, resulting in a special token serialized form.
      Parameters:
      identifier - The identifier to serialize.
      Returns:
      The serialized form of the identifier.
      Throws:
      NullPointerException - if the given identifier is null.
      See Also:
    • deserialize

      public static <I extends Identifier> I deserialize(Class<I> identifierClass, String lexicalForm)
      Deserializes an identifier from its lexical form. Usually the identifier is an Enum and is deserialized from a special token serialized form.

      This implementation currently only recognizes Enum types.

      Type Parameters:
      I - The identifier class.
      Parameters:
      identifierClass - The class of identifier; usually a type of Enum.
      lexicalForm - The lexical form of the identifier being deserialized.
      Returns:
      The identifier represented by the given lexical form.
      Throws:
      NullPointerException - if the given class and/or lexical form is null.
      IllegalArgumentException - if the identifier class is not a recognized type to be deserialized.
      See Also: