Package com.globalmentor.lex
Class Lex
- java.lang.Object
-
- com.globalmentor.lex.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>
Ideserialize(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.
-
-
-
Method Detail
-
serialize
public static java.lang.String serialize(Identifier identifier)
Returns a serialized form of an identifier. Usually the identifier is anEnum
, 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 isnull
.- 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 anEnum
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 ofEnum
.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 isnull
.java.lang.IllegalArgumentException
- if the identifier class is not a recognized type to be deserialized.- See Also:
Enums.getSerializedEnum(Class, String)
-
-