public abstract class Command extends Proc
Modifier and Type | Field and Description |
---|---|
String[] |
args
Command arguments.
|
Exception |
cause
Exception, resulting from command execution.
|
protected Context |
context
Database context.
|
protected InputSource |
in
Optional input source.
|
boolean |
openDB
Indicates if the command requires an opened database.
|
protected MainOptions |
options
Database options.
|
protected PrintOutput |
out
Output stream.
|
protected Performance |
perf
Performance measurements.
|
Perm |
perm
Permission required to execute this command.
|
protected StaticOptions |
soptions
Static options.
|
Modifier | Constructor and Description |
---|---|
protected |
Command(Perm perm,
boolean openDB,
String... args)
Constructor.
|
protected |
Command(Perm perm,
String... args)
Constructor for commands requiring no opened database.
|
Modifier and Type | Method and Description |
---|---|
protected void |
build(CmdBuilder cb)
Builds a string representation from the command.
|
protected static boolean |
close(Context ctx,
String db)
Closes the specified database if it is currently opened and only pinned once.
|
protected boolean |
databases(StringList db,
int index)
Adds the names of the database that has been addressed by the argument index.
|
protected boolean |
error(String msg,
Object... ext)
Adds the error message to the message buffer
info . |
String |
execute(Context ctx)
Executes the command and returns the result as string.
|
void |
execute(Context ctx,
OutputStream os)
Executes the command and prints the result to the specified output
stream.
|
Result |
finish()
Returns a cached result set generated by
AQuery.query(java.lang.String) . |
protected boolean |
finishUpdate(Data data)
Finalizes an update operation.
|
protected <E extends Enum<E>> |
getOption(Class<E> typ)
Returns the specified command option.
|
protected static <E extends Enum<E>> |
getOption(String string,
Class<E> type)
Returns the specified command option.
|
String |
info()
Returns command information.
|
protected boolean |
info(String str,
Object... ext)
Adds information on command execution.
|
void |
init(Context ctx,
OutputStream os)
Initializes the command execution.
|
boolean |
newData(Context ctx)
Closes an open data reference and returns
true if this command will change the
Context.data() reference. |
protected abstract boolean |
run()
Executes the command and serializes the result (internal call).
|
boolean |
run(Context ctx)
Runs the command without permission, data and concurrency checks.
|
boolean |
run(Context ctx,
OutputStream os)
Runs the command without permission, data and concurrency checks.
|
void |
setInput(InputSource input)
Attaches an input source.
|
void |
setInput(InputStream input)
Attaches an input stream.
|
protected boolean |
startUpdate(Data data)
Starts an update operation.
|
boolean |
stoppable()
Returns true if this command can be stopped.
|
boolean |
supportsProg()
Returns true if this command returns a progress value.
|
String |
toString() |
String |
toString(boolean conf)
Returns a string representation of the command.
|
boolean |
updated(Context ctx)
Checks if the command has updated any data.
|
boolean |
updating(Context ctx)
Checks if the command performs updates/write operations.
|
abort, checkStop, databases, det, detail, listen, proc, prog, progress, registered, registered, startTimeout, stop, stopTimeout, tit, title
public final String[] args
public final Perm perm
public final boolean openDB
public Exception cause
protected Performance perf
protected Context context
protected PrintOutput out
protected InputSource in
protected MainOptions options
protected StaticOptions soptions
protected Command(Perm perm, String... args)
perm
- required permissionargs
- argumentspublic final void execute(Context ctx, OutputStream os) throws BaseXException
BaseXException
is thrown.ctx
- database contextos
- output stream referenceBaseXException
- command exceptionpublic final String execute(Context ctx) throws BaseXException
BaseXException
is thrown.ctx
- database contextBaseXException
- command exceptionpublic final void setInput(InputStream input)
input
- input streampublic final void setInput(InputSource input)
input
- input sourcepublic final boolean run(Context ctx)
ctx
- database contextpublic final String info()
public Result finish()
AQuery.query(java.lang.String)
. Will only yield results if
MainOptions.CACHEQUERY
is set, and can only be called once.public boolean updating(Context ctx)
ctx
- database contextpublic boolean updated(Context ctx)
ctx
- database contextpublic boolean newData(Context ctx)
true
if this command will change the
Context.data()
reference. This method is required by the progress dialog in the
frontend.ctx
- database contextpublic boolean supportsProg()
public boolean stoppable()
public final String toString(boolean conf)
conf
- hide confidential informationprotected abstract boolean run() throws IOException
IOException
- I/O exceptionprotected void build(CmdBuilder cb)
cb
- command builderprotected final boolean error(String msg, Object... ext)
info
.msg
- error messageext
- error extensionfalse
protected final boolean info(String str, Object... ext)
str
- information to be addedext
- extended infotrue
protected final <E extends Enum<E>> E getOption(Class<E> typ)
E
- token typetyp
- options enumerationprotected final boolean databases(StringList db, int index)
db
- databasesindex
- argument indexfalse
if database cannot be determined due to glob syntaxprotected final boolean startUpdate(Data data)
data
- data referenceprotected final boolean finishUpdate(Data data)
data
- data referenceprotected static <E extends Enum<E>> E getOption(String string, Class<E> type)
E
- token typestring
- string to be foundtype
- options enumerationprotected static boolean close(Context ctx, String db)
ctx
- database contextdb
- database to be closedpublic void init(Context ctx, OutputStream os)
ctx
- database contextos
- output streampublic boolean run(Context ctx, OutputStream os)
ctx
- database contextos
- output streamCopyright © 2005–2015 BaseX Team. All rights reserved.