Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public interface CommandBinding

The code the build generates for one @Command class, through which the parser creates the command, sets its fields and runs it without reflection.

Applications do not implement this; the build writes one implementation per command and fails if a command cannot be bound.

Methods

public abstract CommandSpec spec()The model of the command, with its subcommands.
public abstract Object create() throws ExceptionA new instance of the command.
public abstract Object convert(int slot, String text) throws ExceptionConverts the text of one value of the argument in slot to the type of its field.
public abstract void set(Object command, int slot, Object value) throws ExceptionStores a converted value in the field of slot.
public abstract void inject(Object command, Object parent, CommandSpec spec) throws ExceptionHands the command the instance of its enclosing command, for a CommandLine.ParentCommand field, and its own model, for a CommandLine.Spec field.
public abstract boolean runnable()Whether the command has a body: it is a Runnable or a Callable.
public abstract int call(Object command) throws ExceptionRuns the command and answers its exit code.

Method details

spec

public abstract CommandSpec spec()
The model of the command, with its subcommands.

create

public abstract Object create() throws Exception
A new instance of the command.

Throws

Exception

convert

public abstract Object convert(int slot, String text) throws Exception
Converts the text of one value of the argument in slot to the type of its field. A failure is reported as an invalid value.

Throws

Exception

set

public abstract void set(Object command, int slot, Object value) throws Exception
Stores a converted value in the field of slot. For an array or a list field, value is a java.util.List of converted elements.

Throws

Exception

inject

public abstract void inject(Object command, Object parent, CommandSpec spec) throws Exception
Hands the command the instance of its enclosing command, for a CommandLine.ParentCommand field, and its own model, for a CommandLine.Spec field.

Throws

Exception

runnable

public abstract boolean runnable()
Whether the command has a body: it is a Runnable or a Callable.

call

public abstract int call(Object command) throws Exception
Runs the command and answers its exit code.

Throws

Exception