com.marklogic.shell
Class Shell

java.lang.Object
  extended bycom.marklogic.shell.Shell
All Implemented Interfaces:
Environment

public class Shell
extends java.lang.Object
implements Environment

Shell Environment for Mark Logic. You can run the shell in batch mode or intercative mode. You can set configuration options by creating a file in your $HOME directory named ".cqshrc".

Author:
Andrew Bruno

Field Summary
static java.lang.String VERSION
          Shell version
 
Fields inherited from interface com.marklogic.shell.Environment
NEWLINE
 
Constructor Summary
Shell()
          Create a new Shell
 
Method Summary
 void checkConnection(java.lang.String user, java.lang.String password, java.lang.String host, int port)
          Tests the connection to Mark Logic.
 void exit()
          Exit the shell cleanly.
 void exitWithError(java.lang.String message)
          Exit the shell with an error message.
 jline.ConsoleReader getConsole()
          The console reader used to read lines of input from the user.
 com.marklogic.xqrunner.XQDataSource getDataSource()
          Returns an XQDataSource using the user, password, host, and port defined in the properties.
 java.io.File getHistoryFile()
          The history file used to store command line history.
 org.apache.commons.cli.Options getOptions()
          The command line options passed into the shell when it was first launched.
 org.apache.commons.configuration.PropertiesConfiguration getProperties()
          The configuration properties for the shell environment.
static void main(java.lang.String[] args)
           
 void print(java.lang.String message)
          Print a message to the console.
 void printError(java.lang.Exception e)
          Print an error to the screen that was caused by an Exception.
 void printError(java.lang.String message)
          Prints an error to the console.
 void printHelp()
          Print the default help screen which will list all the command line options supported by the shell and a brief description of each.
 void printHelp(java.lang.String message)
          Print a message along with the default help screen.
 void printLine(java.lang.String message)
          Print a message to the console with a newline.
 void runXQuery(com.marklogic.xqrunner.XQuery xquery)
          Runs an XQuery statement scrolling the result and displays the execution time in seconds for the query.
 void runXQuery(com.marklogic.xqrunner.XQuery xquery, boolean scrollResult, boolean showTime)
          Runs an XQuery statement and optionally scrolls the result and optionally shows the execution time in seconds for the query.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Shell version

See Also:
Constant Field Values
Constructor Detail

Shell

public Shell()
Create a new Shell

Method Detail

main

public static void main(java.lang.String[] args)

runXQuery

public void runXQuery(com.marklogic.xqrunner.XQuery xquery)
Runs an XQuery statement scrolling the result and displays the execution time in seconds for the query.

Specified by:
runXQuery in interface Environment
Parameters:
xquery -

runXQuery

public void runXQuery(com.marklogic.xqrunner.XQuery xquery,
                      boolean scrollResult,
                      boolean showTime)
Runs an XQuery statement and optionally scrolls the result and optionally shows the execution time in seconds for the query.

Parameters:
xquery -
scrollResult -
showTime -

getDataSource

public com.marklogic.xqrunner.XQDataSource getDataSource()
                                                  throws com.marklogic.xqrunner.XQException
Returns an XQDataSource using the user, password, host, and port defined in the properties.

Specified by:
getDataSource in interface Environment
Throws:
com.marklogic.xqrunner.XQException

checkConnection

public void checkConnection(java.lang.String user,
                            java.lang.String password,
                            java.lang.String host,
                            int port)
                     throws com.marklogic.xqrunner.XQException
Tests the connection to Mark Logic.

Parameters:
user - user name
password - password
host - host
port - port (defaults to 8004)
Throws:
com.marklogic.xqrunner.XQException

printError

public void printError(java.lang.String message)
Prints an error to the console.

Specified by:
printError in interface Environment
Parameters:
message -

printError

public void printError(java.lang.Exception e)
Print an error to the screen that was caused by an Exception. If the Exception is an instance of XDBCXQueryException it will display some verbose information about the XQuery error including line number, context item/postion, uri, variable bindings. For all other exceptions just the message is displayed.

Specified by:
printError in interface Environment
Parameters:
e -

printHelp

public void printHelp()
Print the default help screen which will list all the command line options supported by the shell and a brief description of each.

Specified by:
printHelp in interface Environment

printHelp

public void printHelp(java.lang.String message)
Print a message along with the default help screen.

Specified by:
printHelp in interface Environment
Parameters:
message -

print

public void print(java.lang.String message)
Print a message to the console.

Specified by:
print in interface Environment
Parameters:
message -

printLine

public void printLine(java.lang.String message)
Print a message to the console with a newline.

Specified by:
printLine in interface Environment
Parameters:
message -

exitWithError

public void exitWithError(java.lang.String message)
Exit the shell with an error message.

Specified by:
exitWithError in interface Environment
Parameters:
message -

exit

public void exit()
Exit the shell cleanly.

Specified by:
exit in interface Environment

getConsole

public jline.ConsoleReader getConsole()
The console reader used to read lines of input from the user.


getHistoryFile

public java.io.File getHistoryFile()
The history file used to store command line history. The default for this file is in $HOME/.cqsh_history.


getOptions

public org.apache.commons.cli.Options getOptions()
The command line options passed into the shell when it was first launched.


getProperties

public org.apache.commons.configuration.PropertiesConfiguration getProperties()
The configuration properties for the shell environment. When the shell is first created the file $HOME/.cqshrc is read in if exists. While the shell is running the properties can be used as a place to store environment variables similar to unix shells.

Specified by:
getProperties in interface Environment


Copyright © 2005 Andrew Bruno