Package com.oorian.messaging.commands
Class Command
java.lang.Object
com.oorian.messaging.commands.Command
- Direct Known Subclasses:
ClickCommand,ClientFileUploadCommand,CloseBrowserWindowCommand,CreateTimer,FormSubmitCommand,JavaScriptCommand,LoadImageCommand,LoadImagesCommand,NewBrowserWindowCommand,PrintCommand,SelectTextCommand,SetFocusAndSelectCommand,SetFocusAndValueCommand,SetFocusCommand,SortTable
Abstract base class for all command types in the Oorian messaging system.
This class provides the foundation for creating commands that are sent from the server to the client for execution. Each command has a unique ID and can optionally be associated with a specific DOM element. Commands are serialized to JSON for transmission.
Features:
- Unique command identification
- Optional element association
- JSON serialization support
- Abstract design for extensibility
Usage:
// Extend Command to create custom commands
public class MyCommand extends Command {
public MyCommand(String elementId) {
super("mycommand", elementId);
}
@Override
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.put("id", getId());
json.put("element", getElementId());
return json;
}
}
- Since:
- 2007
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the ID of the DOM element associated with this command.getId()Gets the unique identifier for this command type.voidsetElementId(String elementId) Sets the ID of the DOM element associated with this command.abstract JsonObjecttoJson()Generates the JSON representation of this command.toString()Returns the string representation of this command as JSON.
-
Constructor Details
-
Command
Constructs a new Command with the specified ID.- Parameters:
id- the unique identifier for this command type
-
Command
Constructs a new Command with the specified ID and associated element ID.- Parameters:
id- the unique identifier for this command typeelementId- the ID of the DOM element associated with this command
-
-
Method Details
-
setElementId
Sets the ID of the DOM element associated with this command.- Parameters:
elementId- the element ID to associate with this command
-
getId
Gets the unique identifier for this command type.- Returns:
- the command ID
-
getElementId
Gets the ID of the DOM element associated with this command.- Returns:
- the element ID, or null if no element is associated
-
toJson
Generates the JSON representation of this command.Subclasses must implement this method to provide their specific JSON structure for serialization and transmission to the client.
- Returns:
- a JsonObject containing the command data
-
toString
Returns the string representation of this command as JSON.
-