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:
AnimationCurveParser,ColorParser,ColourParser,CSSParser,DimensionParser,DualDimensionParser,EnumParser,SelectorParser,Vector2f.Parser,Vector2i.Parser,Vector3f.Parser,Vector3i.Parser,Vector4f.Parser,Vector4i.Parser
Abstract class for a stateful parser.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanfail()protected booleangetError()Returns the error message ornull, if the parsing succeeded.Returns the result ornull, if the parsing failed.abstract booleanParses a string.Parses an input string and throws an exception if the parsing fails.protected booleantoString()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
- Throws:
ParsingException- If this parser failed to parse the input string.
-
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:
trueif the parsing succeeded.
-
succeed
-
fail
protected boolean fail() -
fail
-
toString
Description copied from interface:PrintableReturns a string representation of this object.
-