org.basex.core
Class Main

java.lang.Object
  extended by org.basex.core.Main
Direct Known Subclasses:
BaseX, BaseXServer

public abstract class Main
extends java.lang.Object

This is the abstract main class for the starter classes.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
protected  boolean console
          Console mode.
 Context context
          Database context.
protected  boolean newline
          Separate serialized items with newlines.
protected  java.io.OutputStream out
          Output file for queries.
protected  Session session
          Session.
protected  boolean verbose
          Verbose mode.
 
Constructor Summary
protected Main(java.lang.String[] args)
          Constructor.
protected Main(java.lang.String[] args, Context ctx)
          Constructor.
 
Method Summary
protected  void console()
          Launches the console mode, which reads and executes user input.
protected  void execute(Command cmd, boolean info)
          Executes the specified command and optionally prints some information.
protected  void execute(java.lang.String in)
          Parses and executes the input string.
protected abstract  void parseArguments(java.lang.String... args)
          Parses the command-line arguments, specified by the user.
protected  void quit()
          Quits the console mode.
protected abstract  Session session()
          Returns the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

public final Context context
Database context.


out

protected java.io.OutputStream out
Output file for queries.


console

protected boolean console
Console mode. May be set to false during execution.


session

protected Session session
Session.


verbose

protected boolean verbose
Verbose mode.


newline

protected boolean newline
Separate serialized items with newlines.

Constructor Detail

Main

protected Main(java.lang.String[] args)
        throws java.io.IOException
Constructor.

Parameters:
args - command-line arguments
Throws:
java.io.IOException - I/O exception

Main

protected Main(java.lang.String[] args,
               Context ctx)
        throws java.io.IOException
Constructor.

Parameters:
args - command-line arguments
ctx - database context, or null
Throws:
java.io.IOException - I/O exception
Method Detail

console

protected final void console()
Launches the console mode, which reads and executes user input.


quit

protected void quit()
             throws java.io.IOException
Quits the console mode.

Throws:
java.io.IOException - I/O exception

execute

protected final void execute(java.lang.String in)
                      throws java.io.IOException
Parses and executes the input string.

Parameters:
in - input commands
Throws:
java.io.IOException - database exception

execute

protected final void execute(Command cmd,
                             boolean info)
                      throws java.io.IOException
Executes the specified command and optionally prints some information.

Parameters:
cmd - command to be run
info - verbose flag
Throws:
java.io.IOException - I/O exception

session

protected abstract Session session()
                            throws java.io.IOException
Returns the session.

Returns:
session
Throws:
java.io.IOException - I/O exception

parseArguments

protected abstract void parseArguments(java.lang.String... args)
                                throws java.io.IOException
Parses the command-line arguments, specified by the user.

Parameters:
args - command-line arguments
Throws:
java.io.IOException - I/O exception