Package com.globalmentor.lex
Class Lex
java.lang.Object
com.globalmentor.lex.Lex
Constants and utilities for lexical analysis.
- Author:
- Garret Wilson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <I extends Identifier>
Ideserialize
(Class<I> identifierClass, String lexicalForm) Deserializes an identifier from its lexical form.static String
serialize
(Identifier identifier) Returns a serialized form of an identifier.
-
Constructor Details
-
Lex
public Lex()
-
-
Method Details
-
serialize
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:
NullPointerException
- if the given identifier isnull
.- See Also:
-
deserialize
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:
NullPointerException
- if the given class and/or lexical form isnull
.IllegalArgumentException
- if the identifier class is not a recognized type to be deserialized.- See Also:
-