org.eclipse.rdf4j.console.command

## Class ConsoleCommand

- java.lang.Object
- - org.eclipse.rdf4j.console.command.ConsoleCommand

- All Implemented Interfaces:
    Command, Help
  Direct Known Subclasses:
    Clear, Close, Connect, Convert, Create, Disconnect, Drop, Export, Federate, Load, Open, PrintHelp, PrintInfo, QueryEvaluator, SetParameters, Show, Verify

      public abstract class ConsoleCommand
      extends Object
      implements Command, Help

  Abstract command
  Author:
    Bart Hanssens

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.slf4j.Logger` | `LOGGER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConsoleCommand(ConsoleIO consoleIO)` Constructor
    `ConsoleCommand(ConsoleIO consoleIO, ConsoleState state)` Constructor
    `ConsoleCommand(ConsoleIO consoleIO, ConsoleState state, Map<String,ConsoleSetting> settings)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `askProceed(String str, boolean defVal)` Ask user to proceed
    `void` | `execute(String... parameters)` Execute the given parameters.
    `ConsoleIO` | `getConsoleIO()` Get console IO
    `Map<String,ConsoleSetting>` | `getConsoleSettings()` Get console settings map
    `ConsoleState` | `getConsoleState()` Get console state
    `String` | `getHelpLong()` Get long description
    `String` | `getHelpShort()` Get short description, small enough to fit on one console row
    `String[]` | `usesSettings()` Return the names of the settings used.
    `protected void` | `write(String str)` Write a string to the console
    `protected void` | `writeError(String str)` Write a string + newline to the console and to the log as an error
    `protected void` | `writeError(String str, Exception e)` Write a string + message of exception + newline to the console and to the log as an error
    `protected void` | `writeInfo(String str)` Write a string + newline to the console and to the log at level INFO
    `protected void` | `writeln(String str)` Write a string + newline to the console
    `protected void` | `writeUnopenedError()` Write repository not opened error

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

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

    - ### Methods inherited from interface org.eclipse.rdf4j.console.Help

      `getName`

- - ### Field Detail

    - #### LOGGER

          protected final org.slf4j.Logger LOGGER

  - ### Constructor Detail

    - #### ConsoleCommand

          public ConsoleCommand(ConsoleIO consoleIO)

      Constructor
      Parameters:
        `consoleIO` -

    - #### ConsoleCommand

          public ConsoleCommand(ConsoleIO consoleIO,
                                ConsoleState state)

      Constructor
      Parameters:
        `consoleIO` -
        `state` -

    - #### ConsoleCommand

          public ConsoleCommand(ConsoleIO consoleIO,
                                ConsoleState state,
                                Map<String,ConsoleSetting> settings)

      Constructor
      Parameters:
        `consoleIO` - console IO
        `state` - console state
        `settings` - console settings

  - ### Method Detail

    - #### getConsoleIO

          public ConsoleIO getConsoleIO()

      Get console IO
      Returns:
        console IO

    - #### getConsoleState

          public ConsoleState getConsoleState()

      Get console state
      Returns:
        console state

    - #### getConsoleSettings

          public Map<String,ConsoleSetting> getConsoleSettings()

      Get console settings map
      Returns:
        map of console settings

    - #### getHelpShort

          public String getHelpShort()

      Get short description, small enough to fit on one console row
      Specified by:
        `getHelpShort` in interface `Help`
      Returns:
        help string

    - #### getHelpLong

          public String getHelpLong()

      Get long description
      Specified by:
        `getHelpLong` in interface `Help`
      Returns:
        string, can be multiple lines

    - #### usesSettings

          public String[] usesSettings()

      Description copied from interface: `Command`
      Return the names of the settings used.
      Specified by:
        `usesSettings` in interface `Command`
      Returns:
        string array of settings

    - #### execute

          public void execute(String... parameters)
                       throws IOException

      Description copied from interface: `Command`
      Execute the given parameters.
      Specified by:
        `execute` in interface `Command`
      Parameters:
        `parameters` - parameters typed by user
      Throws:
        `IOException` - if a problem occurs reading or writing

    - #### write

          protected void write(String str)

      Write a string to the console
      Parameters:
        `str` - text

    - #### writeln

          protected void writeln(String str)

      Write a string + newline to the console
      Parameters:
        `str` - text

    - #### writeInfo

          protected void writeInfo(String str)

      Write a string + newline to the console and to the log at level INFO
      Parameters:
        `str` - text

    - #### writeError

          protected void writeError(String str)

      Write a string + newline to the console and to the log as an error
      Parameters:
        `str` - text

    - #### writeError

          protected void writeError(String str,
                                    Exception e)

      Write a string + message of exception + newline to the console and to the log as an error
      Parameters:
        `str` - text
        `e` - exception

    - #### writeUnopenedError

          protected void writeUnopenedError()

      Write repository not opened error

    - #### askProceed

          protected boolean askProceed(String str,
                                       boolean defVal)

      Ask user to proceed
      Parameters:
        `str` - question to ask
        `defVal` - default value
      Returns:
        true

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