Class ParsingConfiguration
- Direct Known Subclasses:
ENParsingConfiguration
Parsers,
that allows you to easily parse a string with multiple parsers at once.
ParsedComponents
returned by parsers during the parsing operation are combined into a single
ParseResult.- Since:
- 1.0.0
- Author:
- hashadex
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classImmutable data class representing a final result of parsing using a parsing configuration, combined from multipleParsedComponents. -
Constructor Summary
ConstructorsConstructorDescriptionParsingConfiguration(Set<Parser> parsers) Constructs a ParsingConfiguration containing the specifiedSetofParsers. -
Method Summary
Modifier and TypeMethodDescriptionParses the provided string usingLocalDateTime.now()as reference datetime with allParsersin the configuration and combines returnedParsedComponentsinto a singleParsingConfiguration.ParseResult.parse(String input, LocalDateTime reference) Parses the provided string using allParsersin the configuration and combines returnedParsedComponentsinto a singleParsingConfiguration.ParseResult.
-
Constructor Details
-
ParsingConfiguration
Constructs a ParsingConfiguration containing the specifiedSetofParsers. Parser set must not contain null elements.- Parameters:
parsers-Parserset, not null- Throws:
NullPointerException- ifparsersis null or contains null elements- Since:
- 1.0.0
-
-
Method Details
-
parse
Parses the provided string using allParsersin the configuration and combines returnedParsedComponentsinto a singleParsingConfiguration.ParseResult.Only up to last (by occurrence in text) two
ParsedComponentsare used for theParseResultdateandtimefields. Meaning, if there are multipleParsedComponentscontaining a date returned by the parsers, then only the last component is used for the date field in theParseResult.Use the
parse(String)method to automatically useLocalDateTime.now()as reference datetime.- Parameters:
input- String to be parsedreference-LocalDateTimethat serves as a reference point for parsers that deal with relative date/time expressions, such asENRelativeWordParser- Returns:
ParseResultcomposed from all returnedParsedComponents. Might be empty.- Since:
- 1.0.0
-
parse
Parses the provided string usingLocalDateTime.now()as reference datetime with allParsersin the configuration and combines returnedParsedComponentsinto a singleParsingConfiguration.ParseResult.Only up to last (by occurrence in text) two
ParsedComponentsare used for theParseResultdateandtimefields. Meaning, if there are multipleParsedComponentscontaining a date returned by the parsers, then only the last component is used for the date field in theParseResult.Use the
parse(String, LocalDateTime)method to use a differentLocalDateTimeas reference.- Parameters:
input- String to be parsed- Returns:
ParseResultcomposed from all returnedParsedComponents. Might be empty.- Since:
- 1.0.0
-