org.eclipse.rdf4j.console

## Class ConsoleIO

- java.lang.Object
- - org.eclipse.rdf4j.console.ConsoleIO

-     public class ConsoleIO
      extends Object

  Author:
    Dale Visser

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConsoleIO(ConsoleState info)` Constructor
    `ConsoleIO(InputStream input, OutputStream out, ConsoleState info)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `askProceed(String msg, boolean defaultValue)` Ask if the user wants to continue
    `org.jline.reader.LineReader` | `getLineReader()` Get the JLine line reader
    `OutputStream` | `getOutputStream()` Get JLine terminal output stream
    `protected String` | `readCommand()` Read a command from input
    `String` | `readln(String... message)` Read message from input
    `String` | `readMultiLineInput()` Reads multiple lines from the input until a line that with a '.' on its own is read.
    `String` | `readMultiLineInput(String prompt)` Reads multiple lines from the input until a line that with a '.' on its own is read.
    `String` | `readPassword(String prompt)` Read password from input
    `void` | `setCautious()` Be cautious when executing commands, opposite of force
    `protected void` | `setEcho(boolean echo)` Whether to echo user input to output stream
    `void` | `setForce()` Force commands to proceed
    `void` | `setQuiet(boolean quiet)` Whether to suppress printing of prompts to output
    `boolean` | `wasErrorWritten()` Check if an error was written to the console
    `void` | `write(String string)` Write a string
    `void` | `writeError(String errMsg)` Write an error message
    `void` | `writeln()` Write a newline
    `void` | `writeln(String string)` Write a string, followed by a newline
    `void` | `writeParseError(String prefix, long lineNo, long colNo, String msg)` Write parser error
    `void` | `writeUnopenedError()` Write a "please open first" error message

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ConsoleIO

          public ConsoleIO(InputStream input,
                           OutputStream out,
                           ConsoleState info)
                    throws IOException

      Constructor
      Parameters:
        `input` -
        `out` -
        `info` -
      Throws:
        `IOException`

    - #### ConsoleIO

          public ConsoleIO(ConsoleState info)
                    throws IOException

      Constructor
      Parameters:
        `info` -
      Throws:
        `IOException`

  - ### Method Detail

    - #### getLineReader

          public org.jline.reader.LineReader getLineReader()

      Get the JLine line reader
      Returns:
        line reader

    - #### getOutputStream

          public OutputStream getOutputStream()

      Get JLine terminal output stream
      Returns:
        output stream

    - #### readCommand

          protected String readCommand()
                                throws IOException

      Read a command from input
      Returns:
        one line of input, or null on error
      Throws:
        `IOException`

    - #### readMultiLineInput

          public String readMultiLineInput()
                                    throws IOException

      Reads multiple lines from the input until a line that with a '.' on its own is read.
      Returns:
        input string
      Throws:
        `IOException`

    - #### readMultiLineInput

          public String readMultiLineInput(String prompt)
                                    throws IOException

      Reads multiple lines from the input until a line that with a '.' on its own is read.
      Parameters:
        `prompt` -
      Returns:
        input string
      Throws:
        `IOException`

    - #### readln

          public String readln(String... message)
                        throws IOException

      Read message from input
      Parameters:
        `message` - one or multiple messages
      Returns:
        input string
      Throws:
        `IOException`

    - #### readPassword

          public String readPassword(String prompt)
                              throws IOException

      Read password from input
      Parameters:
        `prompt` - prompt to display
      Returns:
        password string
      Throws:
        `IOException`

    - #### write

          public void write(String string)

      Write a string
      Parameters:
        `string` - string to write

    - #### writeln

          public void writeln()

      Write a newline

    - #### writeln

          public void writeln(String string)

      Write a string, followed by a newline
      Parameters:
        `string` - string to write

    - #### writeError

          public void writeError(String errMsg)

      Write an error message
      Parameters:
        `errMsg` - error message

    - #### writeUnopenedError

          public void writeUnopenedError()

      Write a "please open first" error message

    - #### writeParseError

          public void writeParseError(String prefix,
                                      long lineNo,
                                      long colNo,
                                      String msg)

      Write parser error
      Parameters:
        `prefix` -
        `lineNo` - line number
        `colNo` - column number
        `msg` - message to write

    - #### askProceed

          public boolean askProceed(String msg,
                                    boolean defaultValue)
                             throws IOException

      Ask if the user wants to continue
      Parameters:
        `msg` - confirmation question
        `defaultValue` - true when default is yes
      Returns:
        true when continue
      Throws:
        `IOException`

    - #### setEcho

          protected void setEcho(boolean echo)

      Whether to echo user input to output stream
      Parameters:
        `echo` - true to echo input

    - #### setQuiet

          public void setQuiet(boolean quiet)

      Whether to suppress printing of prompts to output
      Parameters:
        `quiet` - true to suppress printing

    - #### setForce

          public void setForce()

      Force commands to proceed

    - #### setCautious

          public void setCautious()

      Be cautious when executing commands, opposite of force

    - #### wasErrorWritten

          public boolean wasErrorWritten()

      Check if an error was written to the console
      Returns:
        true when error was written

Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.