Interface MqlString

All Superinterfaces:
MqlValue

@Sealed @Beta(CLIENT) public interface MqlString extends MqlValue
A string value in the context of the MongoDB Query Language (MQL).
Since:
4.9.0
  • Method Details

    • toLower

      MqlString toLower()
      Converts this string to lowercase.
      Returns:
      the resulting value.
    • toUpper

      MqlString toUpper()
      Converts this string to uppercase.
      Returns:
      the resulting value.
    • append

      MqlString append(MqlString other)
      The result of appending the other string to the end of this string (strict concatenation).
      Parameters:
      other - the other value.
      Returns:
      the resulting value.
    • length

      MqlInteger length()
      The number of Unicode code points in this string.
      Returns:
      the resulting value.
    • lengthBytes

      MqlInteger lengthBytes()
      The number of UTF-8 encoded bytes in this string.
      Returns:
      the resulting value.
    • substr

      MqlString substr(MqlInteger start, MqlInteger length)
      The substring of this string, from the start index inclusive, and including the specified length, up to the end of the string.

      Warning: the index position is in Unicode code points, not in UTF-8 encoded bytes.

      Parameters:
      start - the start index in Unicode code points.
      length - the length in Unicode code points.
      Returns:
      the resulting value.
    • substr

      default MqlString substr(int start, int length)
      The substring of this string, from the start index inclusive, and including the specified length, up to the end of the string.

      Warning: the index position is in Unicode code points, not in UTF-8 encoded bytes.

      Parameters:
      start - the start index in Unicode code points.
      length - the length in Unicode code points.
      Returns:
      the resulting value.
    • substrBytes

      MqlString substrBytes(MqlInteger start, MqlInteger length)
      The substring of this string, from the start index inclusive, and including the specified length, up to the end of the string.

      The index position is in UTF-8 encoded bytes, not in Unicode code points.

      Parameters:
      start - the start index in UTF-8 encoded bytes.
      length - the length in UTF-8 encoded bytes.
      Returns:
      the resulting value.
    • substrBytes

      default MqlString substrBytes(int start, int length)
      The substring of this string, from the start index inclusive, and including the specified length, up to the end of the string.

      The index position is in UTF-8 encoded bytes, not in Unicode code points.

      Parameters:
      start - the start index in UTF-8 encoded bytes.
      length - the length in UTF-8 encoded bytes.
      Returns:
      the resulting value.
    • parseInteger

      MqlInteger parseInteger()
      Converts this string to an integer.

      This will cause an error if this string does not represent an integer.

      Returns:
      the resulting value.
      Since server release
      4.0
    • parseDate

      MqlDate parseDate()
      Converts this string to a date.

      This method behaves like parseDate(MqlString), with the default format, which is "%Y-%m-%dT%H:%M:%S.%LZ".

      Will cause an error if this string does not represent a valid date string (such as "2018-03-20", "2018-03-20T12:00:00Z", or "2018-03-20T12:00:00+0500").

      Returns:
      the resulting value.
      See Also:
    • parseDate

      MqlDate parseDate(MqlString format)
      Converts this string to a date, using the specified format. UTC is assumed if the timezone offset element is not specified in the format.

      Will cause an error if this string does not match the specified format. Will cause an error if an element is specified that is finer-grained than an element that is not specified, with year being coarsest (for example, minute is specified, but hour is not). Omitted finer-grained elements will be parsed to 0.

      Parameters:
      format - the format.
      Returns:
      the resulting value.
      See Also:
      MongoDB documentation
      Format Specifiers, UTC Offset, and Olson Timezone Identifier
      Since server release
      4.0
    • parseDate

      MqlDate parseDate(MqlString timezone, MqlString format)
      Converts this string to a date, using the specified timezone and format.

      Will cause an error if this string does not match the specified format. Will cause an error if an element is specified that is finer-grained than an element that is not specified, with year being coarsest (for example, minute is specified, but hour is not). Omitted finer-grained elements will be parsed to 0. Will cause an error if the format includes an offset or timezone, even if it matches the supplied timezone.

      Parameters:
      format - the format.
      timezone - the UTC Offset or Olson Timezone Identifier.
      Returns:
      the resulting value.
      See Also:
      MongoDB documentation
      Format Specifiers, UTC Offset, and Olson Timezone Identifier
    • passStringTo

      <R extends MqlValue> R passStringTo(Function<? super MqlString,? extends R> f)
      The result of passing this value to the provided function. Equivalent to f.apply(this), and allows lambdas and static, user-defined functions to use the chaining syntax.
      Type Parameters:
      R - the type of the resulting value.
      Parameters:
      f - the function to apply.
      Returns:
      the resulting value.
      See Also:
    • switchStringOn

      <R extends MqlValue> R switchStringOn(Function<Branches<MqlString>,? extends BranchesTerminal<MqlString,? extends R>> mapping)
      The result of applying the provided switch mapping to this value.
      Type Parameters:
      R - the type of the resulting value.
      Parameters:
      mapping - the switch mapping.
      Returns:
      the resulting value.
      See Also: