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

public abstract class Command extends Object
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 Details

    • Command

      public Command(String id)
      Constructs a new Command with the specified ID.
      Parameters:
      id - the unique identifier for this command type
    • Command

      public Command(String id, String elementId)
      Constructs a new Command with the specified ID and associated element ID.
      Parameters:
      id - the unique identifier for this command type
      elementId - the ID of the DOM element associated with this command
  • Method Details

    • setElementId

      public void setElementId(String elementId)
      Sets the ID of the DOM element associated with this command.
      Parameters:
      elementId - the element ID to associate with this command
    • getId

      public String getId()
      Gets the unique identifier for this command type.
      Returns:
      the command ID
    • getElementId

      public String getElementId()
      Gets the ID of the DOM element associated with this command.
      Returns:
      the element ID, or null if no element is associated
    • toJson

      public abstract JsonObject 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

      public String toString()
      Returns the string representation of this command as JSON.
      Overrides:
      toString in class Object
      Returns:
      the JSON string representation of this command