public abstract class Command extends Progress
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String[] |
args
Command arguments.
|
protected Context |
context
Database context.
|
protected static int |
DATAREF
Commands flag: data reference needed.
|
protected org.xml.sax.InputSource |
in
Optional input source.
|
protected MainProp |
mprop
Main properties.
|
protected PrintOutput |
out
Output stream.
|
protected Performance |
perf
Performance measurements.
|
protected Prop |
prop
Database properties.
|
protected static int |
STANDARD
Commands flag: standard.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Command(int flag,
java.lang.String... arg)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
build(CommandBuilder cb)
Builds a string representation from the command.
|
protected static boolean |
close(Context ctx,
java.lang.String db)
Closes the specified database if it is currently opened and only pinned once.
|
protected boolean |
error(java.lang.String msg,
java.lang.Object... ext)
Adds the error message to the message buffer
info. |
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.
|
protected <E extends java.lang.Enum<E>> |
getOption(java.lang.Class<E> typ)
Returns the specified command option.
|
protected static <E extends java.lang.Enum<E>> |
getOption(java.lang.String s,
java.lang.Class<E> typ)
Returns the specified command option.
|
java.lang.String |
info()
Returns command information.
|
protected boolean |
info(java.lang.String str,
java.lang.Object... ext)
Adds information on command execution.
|
boolean |
newData(Context ctx)
Closes an open data reference and returns
true if this command will change
the Context.data reference. |
java.lang.String |
pinned(Context ctx)
Checks if the database to be updated is opened (pinned) by a process in another JVM.
|
Result |
result()
Returns the result set, generated by a query command.
|
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.
|
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()
Checks if the command has updated any data.
|
boolean |
updating(Context ctx)
Checks if the command performs updates/write operations.
|
protected static final int STANDARD
protected static final int DATAREF
protected final java.lang.String[] args
protected Performance perf
protected Context context
protected PrintOutput out
protected org.xml.sax.InputSource in
protected Prop prop
protected MainProp mprop
protected Command(int flag,
java.lang.String... arg)
flag - command flagsarg - argumentspublic final void execute(Context ctx, java.io.OutputStream os) throws BaseXException
BaseXException is thrown.ctx - database contextos - output stream referenceBaseXException - command exceptionpublic final java.lang.String execute(Context ctx) throws BaseXException
BaseXException is thrown.ctx - database contextBaseXException - command exceptionpublic void setInput(java.io.InputStream is)
is - input streampublic void setInput(org.xml.sax.InputSource is)
is - input sourcepublic final boolean run(Context ctx)
ctx - database contextpublic final java.lang.String info()
public Result result()
Prop.CACHEQUERY is set, and can only be called once.public boolean updating(Context ctx)
ctx - database contextpublic java.lang.String pinned(Context ctx)
ctx - database contextpublic boolean updated()
true.public 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 java.lang.String toString()
toString in class java.lang.Objectprotected abstract boolean run()
throws java.io.IOException
java.io.IOException - I/O exceptionprotected void build(CommandBuilder cb)
cb - command builderprotected final boolean error(java.lang.String msg,
java.lang.Object... ext)
info.msg - error messageext - error extensionfalseprotected final boolean info(java.lang.String str,
java.lang.Object... ext)
str - information to be addedext - extended infotrueprotected final <E extends java.lang.Enum<E>> E getOption(java.lang.Class<E> typ)
E - token typetyp - options enumerationprotected static <E extends java.lang.Enum<E>> E getOption(java.lang.String s,
java.lang.Class<E> typ)
E - token types - string to be foundtyp - options enumerationprotected static boolean close(Context ctx, java.lang.String db)
ctx - database contextdb - database to be closed