Multivalent API

multivalent
Class SemanticEvent

java.lang.Object
  extended by java.util.EventObject
      extended by java.awt.AWTEvent
          extended by multivalent.SemanticEvent
All Implemented Interfaces:
java.io.Serializable

public class SemanticEvent
extends java.awt.AWTEvent

A semantic event, as opposed to a low-level mouse and keyboard events, defines a logical action, such as opening a new document. Rather than directly accomplishing a high-level, logical action, even on itself, a behavior should send a semantic event and give other behaviors a chance to modify it. This also makes these actions available to scripts.

The type of semantic event, or its message, is given by a String field. By using String's, the set of event types is kept open ended. Message detail is given in fields; fields are given suggestive names, but the exact contents depend on the particular semantic event arg, in, out.

Following the Multivalent architectural principle that new behaviors can introduce whatever new structure is needed, any behavior can introduce a semantic event by defining it. Defining means specifying the use of all the fields, usually in the Javadoc comment of a public static final String field that specifies the message. Of course, behaviors should take pains to use existing names when available. The defining behavior usually provides some implementation in its Behavior.semanticEventBefore(SemanticEvent, String) and/or Behavior.semanticEventAfter(SemanticEvent, String) methods. For examples of the standard format for event definitions, see Document.MSG_OPEN, Browser.MSG_NEW, and Action.MSG_EXECUTE.

Semantic events are thrown or fired by adding them to a browser's event queue. Complete semantic events, which should have a handle to the browser in their source field, can be fired via Browser.eventq(String, Object). The convenience method Browser.eventq(AWTEvent) constructs and fires a semantic with the given String message and Object arg. Semantic events are caught in the Behavior.semanticEventBefore(SemanticEvent, String) and Behavior.semanticEventAfter(SemanticEvent, String) methods. Often a behavior will throw and catch the same event.

Version:
$Revision: 1.4 $ $Date: 2003/06/02 05:10:16 $
See Also:
Document, Browser, SystemEvents, Multipage, VMenu, SemanticUI, Serialized Form

Field Summary
static int GENERAL
          Interoperate with java.awt.AWTEvent; the id of a semantic event is given by its message, not by an int.
static int SEMANTIC_FIRST
          Interoperate with java.awt.AWTEvent; the id of a semantic event is given by its message, not by an int.
static int SEMANTIC_LAST
          Interoperate with java.awt.AWTEvent; the id of a semantic event is given by its message, not by an int.
 
Fields inherited from class java.awt.AWTEvent
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASK
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
SemanticEvent(java.lang.Object source, java.lang.String message, java.lang.Object arg)
           
SemanticEvent(java.lang.Object source, java.lang.String message, java.lang.Object arg, java.lang.Object in, java.lang.Object out)
           
 
Method Summary
 boolean equals(java.lang.Object o)
          Two SemanticEvents are equal() iff == is true for all their fields (source, message, arg, in, and out).
 java.lang.Object getArg()
           
 java.lang.Object getIn()
           
 java.lang.String getMessage()
          Messages are intern()'ed, so you can compare it with == rather than Object.equals(Object).
 java.lang.Object getOut()
           
 int hashCode()
           
 void setArg(java.lang.Object arg)
           
 java.lang.String toString()
           
 
Methods inherited from class java.awt.AWTEvent
consume, getID, isConsumed, paramString, setSource
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEMANTIC_FIRST

public static final int SEMANTIC_FIRST
Interoperate with java.awt.AWTEvent; the id of a semantic event is given by its message, not by an int.

See Also:
Constant Field Values

GENERAL

public static final int GENERAL
Interoperate with java.awt.AWTEvent; the id of a semantic event is given by its message, not by an int.

See Also:
Constant Field Values

SEMANTIC_LAST

public static final int SEMANTIC_LAST
Interoperate with java.awt.AWTEvent; the id of a semantic event is given by its message, not by an int.

See Also:
Constant Field Values
Constructor Detail

SemanticEvent

public SemanticEvent(java.lang.Object source,
                     java.lang.String message,
                     java.lang.Object arg)

SemanticEvent

public SemanticEvent(java.lang.Object source,
                     java.lang.String message,
                     java.lang.Object arg,
                     java.lang.Object in,
                     java.lang.Object out)
Method Detail

getMessage

public java.lang.String getMessage()
Messages are intern()'ed, so you can compare it with == rather than Object.equals(Object).


getArg

public java.lang.Object getArg()

setArg

public void setArg(java.lang.Object arg)

getIn

public java.lang.Object getIn()

getOut

public java.lang.Object getOut()

equals

public boolean equals(java.lang.Object o)
Two SemanticEvents are equal() iff == is true for all their fields (source, message, arg, in, and out).

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.AWTEvent

Multivalent API