Class Parser<T>
java.lang.Object
dev.prozilla.pine.common.util.parser.Parser<T>
- Type Parameters:
T- The type of the result.
- All Implemented Interfaces:
Printable
- Direct Known Subclasses:
AnimationCurveParser,ColorParser,ColourParser,DimensionParser,DualDimensionParser,EnumParser,ListParser,SequentialParser,SimpleParser,Vector2f.Parser,Vector2i.Parser,Vector3f.Parser,Vector3i.Parser,Vector4f.Parser,Vector4i.Parser
Abstract class for a stateful parser.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanfail()protected booleangetError()Returns the error message ornull, if the parsing succeeded and removes it.Returns the result ornull, if the parsing failed and removes it.abstract booleanParses a string.parseProperty(StringProperty inputProperty) Creates a property whose value is the result of parsing the value of a string property.Parses an input string and throws an exception if the parsing fails.protected boolean@NotNull StringtoString()Returns a string representation of this object.
-
Field Details
-
GENERIC_ERROR
- See Also:
-
UNEXPECTED_END_OF_INPUT_ERROR
- See Also:
-
-
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 and removes it.- Returns:
- The result
-
getError
Returns the error message ornull, if the parsing succeeded and removes it.- Returns:
- The error message
-
parse
Parses a string.- Parameters:
input- The input string to parse- Returns:
trueif the parsing succeeded.
-
succeed
-
fail
@Contract("-> false") protected boolean fail() -
fail
-
parseProperty
Creates a property whose value is the result of parsing the value of a string property.- Parameters:
inputProperty- The input property- Returns:
- The parsed property.
-
toString
Description copied from interface:PrintableReturns a string representation of this object.
-