Class DefaultRSQLArgumentParser

java.lang.Object
com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.DefaultRSQLArgumentParser
All Implemented Interfaces:
RSQLArgumentParser

public class DefaultRSQLArgumentParser extends Object implements RSQLArgumentParser
Author:
Jeff Fischer, Samarth Dhruva (samarthd)
  • 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 interface RSQLArgumentParser
      Parameters:
      selector - an RSQL selector, usually a field
      operator - operator from the selector to the arguments
      arguments - what will be parsed out
      rootType - 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 interface RSQLArgumentParser
      Parameters:
      selector - an RSQL selector, usually a field
      operator - operator from the selector to the arguments
      arguments - what will be parsed out
      rootType - the type that this is being parsed for. This is generally used at the repository layer so this is usually a repository class
      linkField - Specifies additional information for this selector denoting a Link annotated field. May be null if the selector does not reference a link field.
      Returns:
      typed equivalents of arguments after parsing
    • parseString

      protected String parseString(String argument)
    • parseTemporal

      protected TemporalAccessor parseTemporal(Class<?> selectorType, String argument)
      Parse an ISO8601 string into a TemporalAccessor object. The supported types are ZonedDateTime, LocalDateTime, LocalDate and OffsetDateTime

      For ZonedDateTime, the String must follow the rules of DateTimeFormatter.ISO_ZONED_DATE_TIME. For all other types, the String must follow the rules of DateTimeFormatter.ISO_INSTANT.

      Parameters:
      selectorType - the specific type that the argument should be parsed into
      argument - 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

      protected TemporalAccessor convertFromInstant(@NonNull Instant from, Class<?> to)
    • parseDate

      protected Date parseDate(String argument)
      Parse an ISO8601 String into a Date. This will attempt to parse with both the DateTimeFormatter.ISO_INSTANT and DateTimeFormatter.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

      protected Number parseNumeric(Class<?> selectorType, String argument)
      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 selector
      argument - the argument to convert
    • parseBoolean

      protected Boolean parseBoolean(String argument)
      Parse a String into a Boolean object.
      Parameters:
      argument - the argument to convert