Interface Console

All Known Implementing Classes:
OSGiConsole

@NonNullByDefault public interface Console
This interface must be implemented by consoles which want to use the ConsoleInterpreter. It allows basic output commands.
Author:
Kai Kreuzer - Initial contribution
  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable String
    Returns the user name associated with the console, or null if no user is associated.
    void
    Prints a string to the console without appending a newline.
    default void
    printf(String format, Object... args)
    Prints formatted output to the console.
    void
    Prints a string to the console followed by a newline.
    void
    usage output is treated differently from other output as it might differ between different kinds of consoles
    default String
    readLine(String prompt, @Nullable Character mask)
    Reads a line from the console.
  • Method Details

    • printf

      default void printf(String format, Object... args)
      Prints formatted output to the console. This method formats the given string using the specified arguments and prints it to the console without appending a newline.
      Parameters:
      format - the format string (following String.format(java.lang.String, java.lang.Object...) syntax)
      args - the arguments referenced by the format specifiers in the format string
    • print

      void print(String s)
      Prints a string to the console without appending a newline.
      Parameters:
      s - the string to print
    • println

      void println(String s)
      Prints a string to the console followed by a newline.
      Parameters:
      s - the string to print
    • printUsage

      void printUsage(String s)
      usage output is treated differently from other output as it might differ between different kinds of consoles
      Parameters:
      s - the main usage string (console independent)
    • readLine

      default String readLine(String prompt, @Nullable Character mask) throws IOException
      Reads a line from the console. The prompt is displayed before the line is read.
      Parameters:
      prompt - the prompt to display
      mask - the character to use for masking input (e.g. '*'), or null if no masking is required
      Returns:
      the line read from the console
      Throws:
      IOException - if an I/O error occurs
    • getUser

      default @Nullable String getUser()
      Returns the user name associated with the console, or null if no user is associated.
      Returns:
      the user name, or null if no user is associated