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 class
Immutable 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 specifiedSet
ofParsers
. -
Method Summary
Modifier and TypeMethodDescriptionParses the provided string usingLocalDateTime.now()
as reference datetime with allParsers
in the configuration and combines returnedParsedComponents
into a singleParsingConfiguration.ParseResult
.parse
(String input, LocalDateTime reference) Parses the provided string using allParsers
in the configuration and combines returnedParsedComponents
into a singleParsingConfiguration.ParseResult
.
-
Constructor Details
-
ParsingConfiguration
Constructs a ParsingConfiguration containing the specifiedSet
ofParsers
. Parser set must not contain null elements.- Parameters:
parsers
-Parser
set, not null- Throws:
NullPointerException
- ifparsers
is null or contains null elements- Since:
- 1.0.0
-
-
Method Details
-
parse
Parses the provided string using allParsers
in the configuration and combines returnedParsedComponents
into a singleParsingConfiguration.ParseResult
.Only up to last (by occurrence in text) two
ParsedComponents
are used for theParseResult
date
andtime
fields. Meaning, if there are multipleParsedComponents
containing 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
-LocalDateTime
that serves as a reference point for parsers that deal with relative date/time expressions, such asENRelativeWordParser
- Returns:
ParseResult
composed from all returnedParsedComponents
. Might be empty.- Since:
- 1.0.0
-
parse
Parses the provided string usingLocalDateTime.now()
as reference datetime with allParsers
in the configuration and combines returnedParsedComponents
into a singleParsingConfiguration.ParseResult
.Only up to last (by occurrence in text) two
ParsedComponents
are used for theParseResult
date
andtime
fields. Meaning, if there are multipleParsedComponents
containing 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 differentLocalDateTime
as reference.- Parameters:
input
- String to be parsed- Returns:
ParseResult
composed from all returnedParsedComponents
. Might be empty.- Since:
- 1.0.0
-