org.basex.core
Class Command

java.lang.Object
  extended by org.basex.core.Progress
      extended by org.basex.core.Command
Direct Known Subclasses:
ACreate, AlterUser, AQuery, Check, Close, Copy, CreateBackup, CreateEvent, CreateUser, DropBackup, DropEvent, DropUser, Execute, Exit, Export, Flush, Get, Grant, Help, Info, InfoDB, InfoIndex, Inspect, Kill, List, Open, Password, RepoDelete, RepoInstall, RepoList, Restore, Set, ShowBackups, ShowEvents, ShowSessions, ShowUsers

public abstract class Command
extends Progress

This class provides the architecture for all internal command implementations. It evaluates queries that are sent by the GUI, the client or the standalone version.

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

Field Summary
 java.lang.String[] args
          Command arguments.
 
Fields inherited from class org.basex.core.Progress
listen, updating
 
Method Summary
 java.lang.String execute(Context ctx)
          Executes the command and returns the result as string.
 void execute(Context ctx, java.io.OutputStream os)
          Executes the command and prints the result to the specified output stream.
 java.lang.String info()
          Returns command information.
 boolean newData(Context ctx)
          Closes an open data reference and returns true if this command will change the Context.data reference.
 Result result()
          Returns the result set, generated by a query command.
 boolean run(Context ctx)
          Runs the command without permission, data and concurrency checks.
 boolean run(Context ctx, java.io.OutputStream os)
          Runs the command without permission, data and concurrency checks.
 void setInput(org.xml.sax.InputSource is)
          Attaches an input source.
 void setInput(java.io.InputStream is)
          Attaches an input stream.
 boolean stoppable()
          Returns true if this command can be stopped.
 boolean supportsProg()
          Returns true if this command returns a progress value.
 java.lang.String toString()
           
 boolean updated(Context ctx)
          Checks if the command has updated any data.
 boolean updating(Context ctx)
          Checks if the command performs updates/write operations.
 
Methods inherited from class org.basex.core.Progress
checkStop, detail, listen, progress, startTimeout, stop, stopTimeout, title
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

args

public final java.lang.String[] args
Command arguments.

Method Detail

execute

public final void execute(Context ctx,
                          java.io.OutputStream os)
                   throws BaseXException
Executes the command and prints the result to the specified output stream. If an exception occurs, a BaseXException is thrown.

Parameters:
ctx - database context
os - output stream reference
Throws:
BaseXException - command exception

execute

public final java.lang.String execute(Context ctx)
                               throws BaseXException
Executes the command and returns the result as string. If an exception occurs, a BaseXException is thrown.

Parameters:
ctx - database context
Returns:
string result
Throws:
BaseXException - command exception

setInput

public void setInput(java.io.InputStream is)
Attaches an input stream.

Parameters:
is - input stream

setInput

public void setInput(org.xml.sax.InputSource is)
Attaches an input source.

Parameters:
is - input source

run

public final boolean run(Context ctx)
Runs the command without permission, data and concurrency checks. Should be called with care, and only by other database commands.

Parameters:
ctx - database context
Returns:
result of check

info

public final java.lang.String info()
Returns command information.

Returns:
info string

result

public Result result()
Returns the result set, generated by a query command. Will only yield results if Prop.CACHEQUERY is set, and can only be called once.

Returns:
result set

updating

public boolean updating(Context ctx)
Checks if the command performs updates/write operations.

Parameters:
ctx - database context
Returns:
result of check

updated

public boolean updated(Context ctx)
Checks if the command has updated any data.

Parameters:
ctx - database context
Returns:
result of check

newData

public boolean newData(Context ctx)
Closes an open data reference and returns true if this command will change the Context.data reference. This method is required by the progress dialog in the frontend.

Parameters:
ctx - database context
Returns:
result of check

supportsProg

public boolean supportsProg()
Returns true if this command returns a progress value. This method is required by the progress dialog in the frontend.

Returns:
result of check

stoppable

public boolean stoppable()
Returns true if this command can be stopped. This method is required by the progress dialog in the frontend.

Returns:
result of check

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object

run

public boolean run(Context ctx,
                   java.io.OutputStream os)
Runs the command without permission, data and concurrency checks.

Parameters:
ctx - database context
os - output stream
Returns:
result of check