Class Parser.Builder

  • Enclosing class:
    Parser

    public static class Parser.Builder
    extends Object
    Facilitates the construction of Parser instances. It allows for the step-by-step creation of these objects by providing methods for setting individual attributes. Input validations are performed at each build step.
    Since:
    1.7.0
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • language

        public Parser.Builder language​(@NotNull
                                       @NotNull Language language)
        Sets the programming language intended for parsing.
        Parameters:
        language - The language used for parsing
        Returns:
        this builder
        Throws:
        NullPointerException - if the language is null
        UnsatisfiedLinkError - if the language was not linked to native code
        ABIVersionError - if the language ABI version is incompatible with requirements
      • timeout

        public Parser.Builder timeout​(@NotNull
                                      @NotNull Duration duration)
        Set the maximum duration that parsing should be allowed to take. If parsing time exceeds this value, an exception is thrown. The duration is rounded down to zero if it does not exceed one microsecond. Timeouts are considered disabled when the value is zero.
        Parameters:
        duration - the timeout duration
        Returns:
        this builder
        Throws:
        NullPointerException - if the duration is null
        Since:
        1.8.0
      • timeout

        public Parser.Builder timeout​(long timeout,
                                      @NotNull
                                      @NotNull TimeUnit timeUnit)
        Set the maximum duration that parsing should be allowed to take. If parsing time exceeds this value, an exception is thrown. The duration is rounded down to zero if it does not exceed one microsecond. Timeouts are considered disabled when the value is zero.
        Parameters:
        timeout - the timeout duration amount
        timeUnit - the duration time unit
        Returns:
        this builder
        Throws:
        NullPointerException - if the time unit is null
        IllegalArgumentException - if the timeout value is negative
        Since:
        1.8.0
      • timeout

        public Parser.Builder timeout​(long timeout)
        Set the maximum duration in microseconds that parsing should be allowed to take. If parsing time exceeds this value, an exception is thrown. Timeouts are considered disabled when the value is zero.
        Parameters:
        timeout - the timeout in microseconds
        Returns:
        this builder
        Throws:
        IllegalArgumentException - if the timeout value is negative
        Since:
        1.8.0