Class CLI

Direct Known Subclasses:
BaseX, BaseXServer

public abstract class CLI extends Main
This is the abstract main class for the starter classes.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Details

    • context

      public Context context
      Database context.
    • commands

      protected final ArrayList<Pair<String,String>> commands
      Cached initial commands.
    • out

      protected OutputStream out
      Output file for queries.
    • verbose

      protected boolean verbose
      Verbose mode.
  • Constructor Details

    • CLI

      protected CLI(Context ctx, String... args) throws IOException
      Constructor, assigning the specified context.
      Parameters:
      args - command-line arguments
      ctx - database context (if null, must be assigned later on)
      Throws:
      IOException - I/O exception
  • Method Details

    • execute

      protected final boolean execute(Pair<String,String> command) throws IOException
      Parses and executes the input string.
      Parameters:
      command - base uri (name) and command string (value)
      Returns:
      false if the exit command was sent
      Throws:
      IOException - database exception
    • execute

      protected final boolean execute(CommandParser parser) throws IOException
      Execute the commands from the given command parser.
      Parameters:
      parser - command parser
      Returns:
      false if the exit command was sent
      Throws:
      IOException - database exception
    • execute

      protected final void execute(Command cmd, boolean info) throws IOException
      Executes the specified command and optionally prints some information.
      Parameters:
      cmd - command to be run
      info - verbose flag
      Throws:
      IOException - I/O exception
    • session

      protected final Session session() throws IOException
      Returns the session.
      Returns:
      session
      Throws:
      IOException - I/O exception
    • input

      protected static Pair<String,String> input(String input) throws IOException
      Returns the base URI and the query string for the specified input.
      Parameters:
      input - input
      Returns:
      return base URI and query string
      Throws:
      IOException - I/O exception
    • local

      protected boolean local()
      Indicates if this is a local client.
      Returns:
      local mode