Class DefaultRSQLArgumentParser
java.lang.Object
com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.DefaultRSQLArgumentParser
- All Implemented Interfaces:
RSQLArgumentParser
- Author:
- Jeff Fischer, Samarth Dhruva (samarthd)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected TemporalAccessor
convertFromInstant
(Instant from, Class<?> to) parseArguments
(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType) Returns string-based arguments into their real typed equivalents.parseArguments
(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType, FilterHelper.LinkField linkField) Returns string-based arguments into their real typed equivalents.protected Boolean
parseBoolean
(String argument) Parse a String into a Boolean object.protected Date
Parse an ISO8601 String into aDate
.protected Number
parseNumeric
(Class<?> selectorType, String argument) Parse a String into a number object.protected String
parseString
(String argument) protected TemporalAccessor
parseTemporal
(Class<?> selectorType, String argument) Parse an ISO8601 string into aTemporalAccessor
object.
-
Constructor Details
-
DefaultRSQLArgumentParser
public DefaultRSQLArgumentParser()
-
-
Method Details
-
parseArguments
public List<Object> parseArguments(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType) Description copied from interface:RSQLArgumentParser
Returns string-based arguments into their real typed equivalents.- Specified by:
parseArguments
in interfaceRSQLArgumentParser
- Parameters:
selector
- an RSQL selector, usually a fieldoperator
- operator from the selector to the argumentsarguments
- what will be parsed outrootType
- the type that this is being parsed for. This is generally used at the repository layer so this is usually a repository class- Returns:
- typed equivalents of arguments after parsing
-
parseArguments
public List<Object> parseArguments(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType, FilterHelper.LinkField linkField) Description copied from interface:RSQLArgumentParser
Returns string-based arguments into their real typed equivalents.- Specified by:
parseArguments
in interfaceRSQLArgumentParser
- Parameters:
selector
- an RSQL selector, usually a fieldoperator
- operator from the selector to the argumentsarguments
- what will be parsed outrootType
- the type that this is being parsed for. This is generally used at the repository layer so this is usually a repository classlinkField
- Specifies additional information for this selector denoting aLink
annotated field. May be null if the selector does not reference a link field.- Returns:
- typed equivalents of arguments after parsing
-
parseString
-
parseTemporal
Parse an ISO8601 string into aTemporalAccessor
object. The supported types areZonedDateTime
,LocalDateTime
,LocalDate
andOffsetDateTime
For
ZonedDateTime
, the String must follow the rules ofDateTimeFormatter.ISO_ZONED_DATE_TIME
. For all other types, the String must follow the rules ofDateTimeFormatter.ISO_INSTANT
.- Parameters:
selectorType
- the specific type that the argument should be parsed intoargument
- the argument to convert- Returns:
- a
TemporalAccessor
with the value specified in the given string - Throws:
UnsupportedOperationException
- in the event that there is a parsing error or the selector type is not supported- See Also:
-
convertFromInstant
-
parseDate
Parse an ISO8601 String into aDate
. This will attempt to parse with both theDateTimeFormatter.ISO_INSTANT
andDateTimeFormatter.ISO_ZONED_DATE_TIME
.- Parameters:
argument
- the argument to convert- Returns:
- a
Date
with the value specified in the given string - Throws:
UnsupportedOperationException
- in the event that there is a parsing error
-
parseNumeric
Parse a String into a number object. Strings containing integers are converted to Longs, while decimal strings are converted to BigDecimal.- Parameters:
selectorType
- The type of the selectorargument
- the argument to convert
-
parseBoolean
Parse a String into a Boolean object.- Parameters:
argument
- the argument to convert
-