public class CommandResult extends Object
Command.executeCommand(com.xmlmind.xmledit.gadget.Gadget, java.lang.String, int, int)
.Modifier and Type | Class and Description |
---|---|
static class |
CommandResult.Status |
Modifier and Type | Field and Description |
---|---|
static CommandResult |
CANCELED
A ready-to-use
CANCELED CommandResult having no value
and no details. |
Object |
details
Optional details about the command execution.
|
static CommandResult |
DONE
A ready-to-use
DONE CommandResult having no value
and no details. |
static CommandResult |
FAILED
A ready-to-use
FAILED CommandResult having no value
and no details. |
CommandResult.Status |
status
Status of the command execution.
|
static CommandResult |
STOPPED
A ready-to-use
STOPPED CommandResult having no value
and no details. |
Object |
value
Result of the command execution.
|
Constructor and Description |
---|
CommandResult(CommandResult.Status status,
Object value,
Object details)
Constructs a CommandResult containing specified information.
|
Modifier and Type | Method and Description |
---|---|
static CommandResult |
done(Object value)
Convenience method: equivalent to
new CommandResult(Status.DONE, value, null) . |
static CommandResult |
failed(Object value)
Convenience method: equivalent to
new CommandResult(Status.FAILED, value, null) . |
static boolean |
isDone(CommandResult result)
Convenience method: tests whether specified result is successful.
|
static CommandResult |
stopped(Object value)
Convenience method: equivalent to
new CommandResult(Status.STOPPED, value, null) . |
static CommandResult |
success(Object value,
String... details)
Convenience method: equivalent to
new CommandResult(Status.DONE, value, details) . |
public final CommandResult.Status status
public final Object value
null
, which means: nothing useful.
How to interpret value
depends on status
:
DONE
null
.
STOPPED
null
or some data which normally should be
displayed in a dialog box (e.g. a list of choices letting the user
specify what she/he wants).
If this interactive command can also be executed non-interactively, one possiblity is (1) to let the user specify what she/he wants possibly using means other than a dialog box (2) to create the corresponding "complete parameter" and finally (3) to invoke the command again, this time passing it this "complete parameter" as argument.
CANCELED
null
.
FAILED
null
.
public final Object details
null
.public static final CommandResult DONE
DONE
CommandResult having no value
and no details.public static final CommandResult STOPPED
STOPPED
CommandResult having no value
and no details.public static final CommandResult CANCELED
CANCELED
CommandResult having no value
and no details.public static final CommandResult FAILED
FAILED
CommandResult having no value
and no details.public CommandResult(CommandResult.Status status, Object value, Object details)
public static boolean isDone(CommandResult result)
result
- result to be tested; may be null
which
is considered to be a non-successful result.public static CommandResult done(Object value)
new CommandResult(Status.DONE, value, null)
.public static CommandResult success(Object value, String... details)
new CommandResult(Status.DONE, value, details)
.
If the command execution is successful and
the command is repeatable and/or recordable then
details
field of the result is expected
to be one of:
null
Object
String
s
public static CommandResult stopped(Object value)
new CommandResult(Status.STOPPED, value, null)
.public static CommandResult failed(Object value)
new CommandResult(Status.FAILED, value, null)
.
A a command which reports an error in
its Command.executeCommand(com.xmlmind.xmledit.gadget.Gadget, java.lang.String, int, int)
method should both:
value
error message using an alert dialog box;
value
error message to this method.