Class Lex


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

      Constructors 
      Constructor Description
      Lex()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <I extends Identifier>
      I
      deserialize​(java.lang.Class<I> identifierClass, java.lang.String lexicalForm)
      Deserializes an identifier from its lexical form.
      static java.lang.String serialize​(Identifier identifier)
      Returns a serialized form of an identifier.
      • Methods inherited from class java.lang.Object

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

      • Lex

        public Lex()
    • Method Detail

      • serialize

        public static java.lang.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:
        java.lang.NullPointerException - if the given identifier is null.
        See Also:
        Enums.getSerializationName(Enum)
      • deserialize

        public static <I extends Identifier> I deserialize​(java.lang.Class<I> identifierClass,
                                                           java.lang.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:
        java.lang.NullPointerException - if the given class and/or lexical form is null.
        java.lang.IllegalArgumentException - if the identifier class is not a recognized type to be deserialized.
        See Also:
        Enums.getSerializedEnum(Class, String)