Package dev.prozilla.pine.common.util
Class Parser<T>
java.lang.Object
dev.prozilla.pine.common.util.Parser<T>
- Type Parameters:
T
- The type of the result.
- All Implemented Interfaces:
Printable
- Direct Known Subclasses:
ColorParser
,CSSParser
,DimensionParser
,DualDimensionParser
,EnumParser
Abstract class for a stateful parser.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
fail()
protected boolean
getError()
Returns the error message ornull
, if the parsing succeeded.Returns the result ornull
, if the parsing failed.abstract boolean
Parses a string.Parses an input string and throws an exception if the parsing fails.protected boolean
toString()
Returns a string representation of this object.
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
read
Parses an input string and throws an exception if the parsing fails.- Parameters:
input
- The input string to parse- Returns:
- The parsed value or
null
, if the parsing failed.
-
getResult
Returns the result ornull
, if the parsing failed.- Returns:
- The result
-
getError
Returns the error message ornull
, if the parsing succeeded.- Returns:
- The error message
-
parse
Parses a string.- Parameters:
input
- The input string to parse- Returns:
true
if the parsing succeeded.
-
succeed
-
fail
protected boolean fail() -
fail
-
toString
Description copied from interface:Printable
Returns a string representation of this object.
-