public class ParserUtil extends Object
| Constructor and Description |
|---|
ParserUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
addParser(Class<T> c,
Parser<T> p)
Adds a parser for the input class
|
static <T> Parser<T> |
findParserOrNull(Class<T> cl)
Returns a parser for the input class or null if no parser is found
|
static <T> Parser<T> |
getParser(Class<T> cl)
Returns a parser for the input class
|
static boolean |
hasParser(Class<?> cl)
Checks if a parser for the class is available
|
static <T> T |
parse(Class<T> cl,
String x)
Parses a String into an Object of a defined type
|
static <T> T |
parseOrNull(Class<T> cl,
String x)
Parses a String into an object of input type.
|
public static <T> T parse(Class<T> cl, String x) throws ParseException, ParserNotFoundException
T - type of the returned objectcl - class of the returned objectx - String to parseParseException - thrown if the string can not be parsedParserNotFoundException - thrown if no parser is found for the object typepublic static boolean hasParser(Class<?> cl)
cl - input classpublic static <T> Parser<T> getParser(Class<T> cl) throws ParserNotFoundException
T - type of classcl - input classParserNotFoundException - thrown if no parser is foundpublic static <T> Parser<T> findParserOrNull(Class<T> cl)
T - type of classcl - input classpublic static <T> T parseOrNull(Class<T> cl, String x)
T - type of resulting objectcl - Class of resulting objectx - String to parseCopyright © 2017. All rights reserved.