org.instantreality.InstantIO
Class Slot

java.lang.Object
  extended by org.instantreality.InstantIO.Slot
Direct Known Subclasses:
InSlot, OutSlot

public abstract class Slot
extends java.lang.Object

Abstract superclass of OutSlots and InSlots.

Author:
Patrick Dähne

Field Summary
static int In
          Gets returned by the getDirection method when the Slot is an InSlot.
static int Out
          Gets returned by the getDirection method when the Slot is an OutSlot.
 
Constructor Summary
protected Slot(java.lang.Class type)
          Creates a new Slot object with a type.
protected Slot(java.lang.Class type, java.lang.String description)
          Creates a new Slot object with a type and a description.
 
Method Summary
 java.lang.String getDescription()
          Returns the description of the Slot.
abstract  int getDirection()
          Returns the direction of the Slot.
 java.lang.Class getType()
          Returns the type of data that can be sent to or received from this Slot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

In

public static final int In
Gets returned by the getDirection method when the Slot is an InSlot.

See Also:
Constant Field Values

Out

public static final int Out
Gets returned by the getDirection method when the Slot is an OutSlot.

See Also:
Constant Field Values
Constructor Detail

Slot

protected Slot(java.lang.Class type)
Creates a new Slot object with a type.

Parameters:
type - The type of data that can be sent to or received from this Slot. Slots can only connect to other Slots that have the same type of data. To use basic Java types (e.g. boolean, int or float) you have to use the wrapper classes provided by Java (e.g. Boolean, Integer or Float).

Slot

protected Slot(java.lang.Class type,
               java.lang.String description)
Creates a new Slot object with a type and a description.

Parameters:
type - The type of data that can be sent to or received from this Slot. Slots can only connect to other Slots that have the same type of data. To use basic Java types (e.g. boolean, int or float) you have to use the wrapper classes provided by Java (e.g. Boolean, Integer or Float).
description - The description of this Slot. The description is not used by the system in any way. It primarily serves documentation purposes. Some user interfaces that allow to manage the system print the description alongside with the InSlot.
Method Detail

getType

public final java.lang.Class getType()
Returns the type of data that can be sent to or received from this Slot. The Slots can only connect to other Slots that use the same type of data. You specify the data type when you create a Slot.

The following example demonstrates how to check if an OutSlot and an InSlot can be connected to each other:

 OutSlot outSlot = ...;
 InSlot inSlot = ...;
 if (outSlot.getType() == inSlot.getType())
 {
   // They can be connected
 }
 else
 {
   // They cannot be connected
 }
 

Returns:
The type of data.
See Also:
Constructor, Constructor

getDescription

public final java.lang.String getDescription()
Returns the description of the Slot. The description is a string that is not used by the system in any way. It primarily serves documentation purposes. Some user interfaces that allow to manage the system print the description string alongside the Slot (for example, the web interface). You specify the description when you create a Slot.

The following example demonstrates how to print the description of an OutSlot to the console:

 OutSlot outSlot = ...;
 System.out.println("Description = " + outSlot.getDescription());
 

Returns:
The description string.
See Also:
Constructor

getDirection

public abstract int getDirection()
Returns the direction of the Slot. This is the constant In when the Slot is an InSlot, and Out when the Slot is an OutSlot.

The following example demonstrates how to determine if a given Slot is an InSlot or an OutSlot:

 Slot slot = ...;
 switch (slot.getDirection())
 {
 case Slot.In:
   // We have an InSlot
   break;
 case Slot.Out:
   // We have an OutSlot
   break;
 }
 

Returns:
The direction