DRCL JavaSim API

drcl.comp
Class Component

java.lang.Object
  |
  +--drcl.DrclObj
        |
        +--drcl.comp.Component
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, java.io.Serializable
Direct Known Subclasses:
ActiveQueue, Bouncer, BulkSink, BulkSource, ByteStreamNetPeer, Classifier, ComponentTemplate, CoreServiceLayer, CSLBuilder, Extension, Identity, Launcher, Link, Module, Network, NI, Node, NodeBuilder, PktFilterSwitch, RT, Shell, System, Talk, Term, TrafficComponent, WrapperComponent

public class Component
extends DrclObj

Component is the base class for implementing components in the Autonomous Component Architecture (ACA).

A component in ACA is analogous to an IC chip in digital circuit design. As pins to an IC chip, ports are the only means with which a component is interfaced with the rest of the system. And as the specification in a data cookbook in digital circuit desgin, a component is fully specified by contracts. A contract describes how a a component expects and responds what format of data to arrive and send at which ports.

When data arrives at a component, a new thread is spawned and carries out the process() method to process the data at the component. The data processing must follow the contract(s) that are obtained by getContract(Port). There are a rich set of data structures and methods defined in a component. Some of which are facilities that facilitate using a component in a system. Some of which are methods defined in ACA which a subclass must implement. Some of which are API's that writing a component subclass may take advantage of. All these are categorized and described as follows:

See Also:
Port, Contract, ContractMultiple, Serialized Form

Inner Class Summary
static class Component.LockPack
           
 
Field Summary
static int FLAG_COMPONENT_NOTIFICATION
           
static int FLAG_DEBUG_ENABLED
           
static int FLAG_DIRECT_OUTPUT_ENABLED
           
static int FLAG_ENABLED
          Bit mask of the enabled flag.
static int FLAG_ERROR_ENABLED
          Bit mask of the enabled flag.
static int FLAG_EVENT_ENABLED
           
static int FLAG_GARBAGE_DISPLAY_ENABLED
           
static int FLAG_GARBAGE_ENABLED
           
static int FLAG_PORT_NOTIFICATION
           
static int FLAG_STARTED
           
static int FLAG_STOPPED
           
static int FLAG_TRACE_ENABLED
           
static int FLAG_UNDEFINED_START
           
 java.lang.String id
          Identification, must be unique within the parent component.
 Port infoPort
          The information port of this component.
 Component.LockPack lockHead
           
 java.lang.String name
          Descriptive name for the component.
 Component parent
          Parent component.
static java.lang.String PortGroup_DEFAULT_GROUP
          The default port group.
static java.lang.String PortGroup_EVENT
          The event port group.
static java.lang.String PortGroup_SERVICE
          The service port group.
static Component Root
          The root of the component system.
static java.lang.String Trace_DATA
          Data arrival trace type.
static java.lang.String Trace_SEND
          Data sending trace type.
 
Constructor Summary
Component()
           
Component(java.lang.String id_)
           
 
Method Summary
protected  void _resume()
          This method is invoked in a new thread context when resume() is called.
protected  void _start()
          This method is invoked in a new thread context when run() is called.
protected  void _stop()
          This method is invoked in a new thread context when stop() is called.
 void addComponent(Component c_)
          Adds a child component.
 void addComponent(Component c_, boolean inheritRuntime_)
          Adds a child component.
 Port addEventPort(java.lang.String pid_)
          Adds an event port to the default port group of this component.
 Port addEventPort(java.lang.String pgid_, java.lang.String pid_)
          Adds an event port to the specified port group of this component.
 Port addForkPort(java.lang.String pid_)
          Adds a fork port to the default port group of this component.
 Port addPort(Port new_, java.lang.String newID_)
          Adds a port to the default port group with the given port id, It assigns an ID if the given id is null.
 Port addPort(Port new_, java.lang.String newID_, boolean isRemovable_)
          Adds a port to the default port group with the given port id, It assigns an ID if the given id is null.
 Port addPort(Port new_, java.lang.String groupID_, java.lang.String newID_)
          Adds a port with the given group id and the port id.
 Port addPort(Port new_, java.lang.String groupID_, java.lang.String newID_, boolean isRemovable_)
          Adds a port with the given group id and the port id.
 Port addPort(java.lang.String id_)
          Creates a port in the default port group with the given port id, It assigns an ID if the given id is null.
 Port addPort(java.lang.String id_, boolean isRemovable_)
          Creates a port in the default port group with the given port id, It assigns an ID if the given id is null.
 Port addPort(java.lang.String groupID_, java.lang.String id_)
          Creates a port with the given group id and the port id.
 Port addPort(java.lang.String groupID_, java.lang.String id_, boolean isRemovable_)
          Creates a port with the given group id and the port id.
 Port addServerPort(java.lang.String pid_)
          Adds a server port to the default port group of this component.
 Port addServerPort(java.lang.String pgid_, java.lang.String pid_)
          Adds a server port to the specified port group of this component.
 void cancelFork(ACATimer handle_)
          Cancels a fork event.
protected  void componentAdded(Component c_)
          The hookup method for subclasses to handle the event when a child component is added.
protected  void componentRemoved(Component c_)
          The hookup method for subclasses to handle the event when a child component is removed.
 boolean connect(Component c_, boolean shared_)
          stablishes a two-way connection between this and the specified component.
 boolean containsComponent(Component c_)
          Returns true if the specified component is an immediate child of this component.
 boolean containsComponent(java.lang.String id_)
          Returns true if the ID matches one of its child components'.
 boolean containsPort(Port p_)
          Returns true if the component owns the port.
 void debug(java.lang.Object info_)
          Send debug information at infoport.
 void disconnectAll()
          Disconnects all the ports of this component.
 void disconnectAllPeers()
          Disconnects this component from the rest of the system.
 void disconnectAllPorts(java.lang.String groupID_)
          Disconnects all the ports in the port group.
 void drop(java.lang.Object o_)
          Drops the garbage at infoport.
 void drop(java.lang.Object o_, java.lang.String description_)
          Drops the garbage with description at infoport.
 void duplicate(java.lang.Object source_)
          Duplicates the content of source_, including ID, name, child components and connections among them, to this component.
 void error(java.lang.Object data_, java.lang.String method_, Port p_, java.lang.Object error_)
          Sends an error message at infoport.
 void error(java.lang.String method_, java.lang.Object error_)
          Sends an error message at infoport.
 void expose(Component child_)
          Makes the child component receives all the data as this parent component does.
 void exposeEventPorts(Component c_)
          Exposes the event ports of the given child component.
 Port exposePort(Component child_, java.lang.String pid_)
          Creates a port that proxies for the client port, specified by the child component, group id and port id.
 Port exposePort(Component child_, java.lang.String groupID_, java.lang.String id_)
          Creates a shadow port for a port of the child component's, specified by the child component, the port group id and the port id.
 Port exposePort(Component child_, java.lang.String groupID_, java.lang.String id_, java.lang.String mygroupID_, java.lang.String myID_)
          Creates a shadow port, with the given group id and the port id, for a port of the child component, specified by the child component, the port group id and the port id.
 Port exposePort(Port client_)
          Creates a shadow port for the client port and makes it have the same group ID and port ID as the client's.
 Port exposePort(Port client_, java.lang.String mygroupID_, java.lang.String myID_)
          Creates a shadow port, with the given group id and the port id, for the client port.
 Port findAvailable()
          Returns an unconnected port from the default connection port group of this component.
 Port findAvailable(java.lang.String groupID_)
          Returns an unconnected port from the specified port group.
 Port findAvailable(java.lang.String groupID_, java.lang.String portType_)
          Returns an unconnected port of the given port type from the specified port group.
protected  void finishing()
          Notifies of the end of data processing (for performance-aware components).
 ACATimer fork(Port which_, java.lang.Object data_, double duration_)
          Sets up a fork event.
 ACATimer forkAt(Port which_, java.lang.Object data_, double time_)
          Sets up a fork event.
 Component[] getAllComponents()
          Returns all the child components.
 Port[] getAllPorts()
          Returns all the ports of this component.
 Port[] getAllPorts(java.lang.String groupID_)
          Returns all the ports of the port group in this component.
 Wire[] getAllWiresInside()
          Returns all the wires that the ports of the child components are attached to.
 Wire[] getAllWiresInsideOut()
          Returns all the wires that the ports of this component and the child components are attached to.
 Wire[] getAllWiresOut()
          Returns all the wires that the ports of this component are attached to.
 Component getComponent(java.lang.String id_)
          Returns the child given the component ID.
 long getComponentFlag()
          Returns the info flag of this component.
 long getComponentFlag(long mask_)
          Returns portion of the info flag masked by mask_
static Contract getContract(Port p_)
          Returns the contract associated with the port.
static java.util.Hashtable getContractHT()
          For debugging purposes.
static java.util.Hashtable getContractHT(java.lang.String name_)
          For debugging purposes.
 java.lang.String getDebugFlagsInBinary()
          Prints the debug level flags as bitset; 1 as enabled and 0 disabled.
 java.lang.String[] getDebugLevelNames()
          Returns the names of defined debug levels; subclasses should override this method if debug levels are defined.
protected  ForkManager getForkManager()
          Returns the fork runtime associated with this component.
 java.lang.String getID()
          Returns the identification of the component.
 java.lang.String getName()
          Returns the (informational) name of the component.
 Component getParent()
          Returns the parent component.
 Port getPort(java.lang.String id_)
          Returns the port in the default group given the port ID.
 Port getPort(java.lang.String groupID_, java.lang.String id_)
          Returns the port given the group ID and the port ID.
 Component getRoot()
          Returns the root component of the component system.
protected  ACARuntime getRuntime()
          Returns the runtime associated with this component.
 double getTime()
          Returns the system time.
 void iduplicate(Component that_)
          Duplicates the internal structure of the source component.
 java.lang.String info()
          Returns information regarding this component.
 boolean isAncestorOf(Component c_)
          Returns true if the component hierarchy rooted at this component contains the specified component.
protected  boolean isComponentNotificationEnabled()
          Returns true if the component-added notification flag is enabled.
 boolean isContainer()
          Returns true if this component is a container.
 boolean isDebugEnabled()
          Returns true if the debug flag is on.
 boolean isDebugEnabledAt(int level_)
          Returns true if the flag(s) is(are) enabled at the specified debug level(s).
 boolean isDirectOutputEnabled()
          Returns true if the error notice flag is on.
 boolean isEnabled()
          Returns true if the component is enabled for receiving data.
 boolean isErrorNoticeEnabled()
          Returns true if the error notice flag is on.
 boolean isEventExportEnabled()
          Returns true if the state report flag is on.
 boolean isGarbageDisplayEnabled()
          Returns true if the garbage display flag is on.
 boolean isGarbageEnabled()
          Returns true if the garbage flag is on.
protected  boolean isPortNotificationEnabled()
          Returns true if the port-added notification flag is enabled.
 boolean isPortRemovable(Port p_)
          Returns true if the port is removable from this component.
 boolean isStarted()
          Returns true if this component is an ActiveComponent and has started to run (using the run() method).
 boolean isStopped()
           
 boolean isTraceEnabled()
          Returns true if the trace flag is on.
 void lock(java.lang.Object o_)
          Grabs the lock of the object.
 void notify(java.lang.Object o_)
          Notifies on the object.
 void notifyAll(java.lang.Object o_)
          Notifies all the execution contexts that wait on the object.
 void operate(double time_, java.lang.String op_)
          Operates all the active components under this component hierarchy.
protected  void portAdded(Port p_)
          The hookup method for subclasses to handle the event when the port p_ is added to the component.
protected  void portRemoved(Port p_)
          The hookup method for subclasses to handle the event when the port p_ is removed from the component.
protected  void process(java.lang.Object data_, Port inPort_)
          The main callback method of a component.
 void reboot()
          Resets the component and the associated runtime.
 void removeAll()
          Removes all the children and ports.
 void removeAllComponents()
          Removes all the child components.
 void removeAllPorts()
          Removes all the ports.
 void removeAllPorts(java.lang.String groupID_)
          Removes all the ports of the port group.
 Component removeComponent(Component c_)
          Removes a child from this component.
 Component removeComponent(java.lang.String id_)
          Removes a child given the component ID.
 Port removePort(Port p_)
          Removes the port.
 Port removePort(java.lang.String id_)
          Removes the port in the default port group.
 Port removePort(java.lang.String groupID_, java.lang.String id_)
          Removes the port given the group id and the port id.
 void reset()
          Resets the component for being used anew.
 void resume()
          Resumes all the active components under this component hierarchy.
 void run()
          Starts all the active components under this component hierarchy.
 void sduplicate(Component that_)
          Duplicates the child components and the structure (including the shadow connections) from the source component.
 ACATimer send(Port which_, java.lang.Object data_, double duration_)
          Sets up a delayed send event.
 ACATimer sendAt(Port which_, java.lang.Object data_, double time_)
          Sets up a delayed send event.
 void setComponentFlag(long flag_)
          Sets the info flag of this component.
 void setComponentFlag(long mask_, boolean v_)
          Sets the info flag at the 1's in mask_.
protected  void setComponentNotificationEnabled(boolean v_)
          Turns on/off the component-added notification flag.
protected static void setContract(java.lang.Class class_, java.lang.String id_, Contract c_)
          Associates a port or a set of ports with the contract.
 void setDebugEnabled(boolean v_)
          Turns on/off the debug flag.
 void setDebugEnabled(boolean v_, boolean recursive_)
          Turns on/off the debug flag recursively.
 void setDebugEnabledAt(boolean v_, int level_)
          Enables/disables one or more debug levels.
 void setDebugEnabledAt(boolean v_, int[] levels_)
          Enables/disables one or more debug levels.
 void setDebugEnabledAt(boolean v_, java.lang.String[] levels_)
          Enables/disables one or more debug levels given the debug level name(s).
 void setDirectOutputEnabled(boolean v_)
          Turns on/off the direct-output flag.
 void setDirectOutputEnabled(boolean v_, boolean recursive_)
          Turns on/off the direct-output flag recursively.
 void setEnabled(boolean v_)
          Enables/disables the component (and child components) for receiving data.
 void setErrorNoticeEnabled(boolean v_)
          Turns on/off the error notice flag.
 void setErrorNoticeEnabled(boolean v_, boolean recursive_)
          Turns on/off the error notice flag recursively.
 void setEventExportEnabled(boolean v_)
          Turns on/off the state report flag.
 void setEventExportEnabled(boolean v_, boolean recursive_)
          Turns on/off the state report flag recursively.
 void setExecutionBoundary(boolean v_)
           
 void setGarbageDisplayEnabled(boolean v_)
          Turns on/off the garbage display flag.
 void setGarbageDisplayEnabled(boolean v_, boolean recursive_)
          Turns on/off the garbage display flag recursively.
 void setGarbageEnabled(boolean v_)
          Turns on/off the garbage flag.
 void setGarbageEnabled(boolean v_, boolean recursive_)
          Turns on/off the garbage flag recursively.
 java.lang.String setID()
          This method automatically finds a valid ID in the parent component for this component.
 void setID(java.lang.String newID_)
          Sets the identification of the component.
 void setName(java.lang.String name_)
          Sets the (informational) name of this component.
 void setPort(Port newPort_, java.lang.String id_)
          Replaces the port in the default port group, given the port id, with newPort.
 void setPort(Port newPort_, java.lang.String groupID_, java.lang.String id_)
          Replaces the port, the given group id and the port id, with newPort.
protected  void setPortNotificationEnabled(boolean v_)
          Turns on/off the port-added notification flag.
protected  void setPortRemovable(Port p_, boolean v_)
          Sets the port to be (un)removable.
protected  void setRuntime(ACARuntime m_)
          Sets the runtime associated with this component.
 void setTraceEnabled(boolean v_)
          Turns on/off the component trace flag and all ports' (except infoPort) trace flags.
 void setTraceEnabled(boolean v_, boolean recursive_)
          Turns on/off the trace flags recursively.
 void sleepFor(double time_)
          Sleeps for time seconds.
 void sleepUntil(double time_)
          Sleeps util the time specified.
 void stop()
          Stops all the active components under this component hierarchy.
 java.lang.String toString()
          Returns the full path of the component.
 void unexpose(Component child_)
          Undoes what expose(Component) did.
 void unlock(java.lang.Object o_)
          Releases the lock of the object.
 void useLocalForkManager()
          Creates and associates a local fork runtime with this component.
 void useLocalForkManager(boolean simple_)
          Creates and associates a local fork runtime with this component.
 void wait(java.lang.Object o_)
          Waits on the object until being notified.
 
Methods inherited from class drcl.DrclObj
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PortGroup_DEFAULT_GROUP

public static final java.lang.String PortGroup_DEFAULT_GROUP
The default port group.

PortGroup_EVENT

public static final java.lang.String PortGroup_EVENT
The event port group.

PortGroup_SERVICE

public static final java.lang.String PortGroup_SERVICE
The service port group.

id

public java.lang.String id
Identification, must be unique within the parent component. ID must be set using setID() or setID(String), otherwise no check is done for components with duplicate ID.

name

public java.lang.String name
Descriptive name for the component. Default is equal to the name of the class.

parent

public Component parent
Parent component.

infoPort

public final Port infoPort
The information port of this component. A component sends out useful information regarding the operations of this component at this port. Specifically, a component may send out send out the following types of messages at this port: error, garbage, trace, and debug.

FLAG_ENABLED

public static final int FLAG_ENABLED
Bit mask of the enabled flag.

FLAG_ERROR_ENABLED

public static final int FLAG_ERROR_ENABLED
Bit mask of the enabled flag.

FLAG_GARBAGE_ENABLED

public static final int FLAG_GARBAGE_ENABLED

FLAG_GARBAGE_DISPLAY_ENABLED

public static final int FLAG_GARBAGE_DISPLAY_ENABLED

FLAG_DEBUG_ENABLED

public static final int FLAG_DEBUG_ENABLED

FLAG_TRACE_ENABLED

public static final int FLAG_TRACE_ENABLED

FLAG_EVENT_ENABLED

public static final int FLAG_EVENT_ENABLED

FLAG_COMPONENT_NOTIFICATION

public static final int FLAG_COMPONENT_NOTIFICATION

FLAG_PORT_NOTIFICATION

public static final int FLAG_PORT_NOTIFICATION

FLAG_DIRECT_OUTPUT_ENABLED

public static final int FLAG_DIRECT_OUTPUT_ENABLED

FLAG_STARTED

public static final int FLAG_STARTED

FLAG_STOPPED

public static final int FLAG_STOPPED

FLAG_UNDEFINED_START

public static final int FLAG_UNDEFINED_START

Trace_DATA

public static final java.lang.String Trace_DATA
Data arrival trace type.

Trace_SEND

public static final java.lang.String Trace_SEND
Data sending trace type.

lockHead

public Component.LockPack lockHead

Root

public static Component Root
The root of the component system.
Constructor Detail

Component

public Component()

Component

public Component(java.lang.String id_)
Parameters:
id_ - the component ID.
Method Detail

reset

public void reset()
Resets the component for being used anew. All the internal variables must be set to the initial state. All the ports and child components are reset as well.

reboot

public void reboot()
Resets the component and the associated runtime. This method is usually used to reset a component system that is associated with a runtime. All the internal variables must be set to the initial state. All the ports and child components are reset as well.

_start

protected void _start()
This method is invoked in a new thread context when run() is called. An ActiveComponent subclass must override this method to start this component.

_stop

protected void _stop()
This method is invoked in a new thread context when stop() is called. An ActiveComponent subclass must override this method to stop this component.

_resume

protected void _resume()
This method is invoked in a new thread context when resume() is called. An ActiveComponent subclass must override this method to resume this component.

run

public final void run()
Starts all the active components under this component hierarchy.

stop

public final void stop()
Stops all the active components under this component hierarchy.

resume

public final void resume()
Resumes all the active components under this component hierarchy.

operate

public final void operate(double time_,
                          java.lang.String op_)
Operates all the active components under this component hierarchy. Available operators are "start", "stop" and "resume". This is the general form of run(), stop() and resume().
Parameters:
time_ - operating the component at the specified time later.
op_ - the operator.

getParent

public Component getParent()
Returns the parent component.

setID

public void setID(java.lang.String newID_)
Sets the identification of the component. It returns false if same id exists for some component within the same parent. Id can be assigned before the component is added to a parent component.

setID

public java.lang.String setID()
This method automatically finds a valid ID in the parent component for this component. The naming rule and search order is class_name, class_name(2), class_name(3) and so on.

getID

public java.lang.String getID()
Returns the identification of the component.

setName

public void setName(java.lang.String name_)
Sets the (informational) name of this component. By default, the name of a component is set to its class name.

getName

public java.lang.String getName()
Returns the (informational) name of the component.

toString

public java.lang.String toString()
Returns the full path of the component.
Overrides:
toString in class DrclObj

isStarted

public final boolean isStarted()
Returns true if this component is an ActiveComponent and has started to run (using the run() method). A started component cannot be started again until being reset (reset()).

isStopped

public final boolean isStopped()

process

protected void process(java.lang.Object data_,
                       Port inPort_)
The main callback method of a component. Being invoked when data arrives at a port of its.
Parameters:
data_ - the arrival data.
inPort_ - the port where the data arrives.

addEventPort

public final Port addEventPort(java.lang.String pid_)
Adds an event port to the default port group of this component.

addEventPort

public final Port addEventPort(java.lang.String pgid_,
                               java.lang.String pid_)
Adds an event port to the specified port group of this component.

addServerPort

public final Port addServerPort(java.lang.String pid_)
Adds a server port to the default port group of this component.

addServerPort

public final Port addServerPort(java.lang.String pgid_,
                                java.lang.String pid_)
Adds a server port to the specified port group of this component.

addForkPort

public final Port addForkPort(java.lang.String pid_)
Adds a fork port to the default port group of this component.

getPort

public final Port getPort(java.lang.String groupID_,
                          java.lang.String id_)
Returns the port given the group ID and the port ID.

getPort

public final Port getPort(java.lang.String id_)
Returns the port in the default group given the port ID.

getAllPorts

public final Port[] getAllPorts()
Returns all the ports of this component.

getAllPorts

public final Port[] getAllPorts(java.lang.String groupID_)
Returns all the ports of the port group in this component.

removeAllPorts

public final void removeAllPorts()
Removes all the ports.

removeAllPorts

public final void removeAllPorts(java.lang.String groupID_)
Removes all the ports of the port group.

removePort

public final Port removePort(java.lang.String groupID_,
                             java.lang.String id_)
Removes the port given the group id and the port id. It does not disconnect the port. The other removePort() methods end up with calling this method.
Parameters:
groupID_ - group ID of the port.
id_ - ID of the port.
Returns:
the removed port.

removePort

public final Port removePort(Port p_)
Removes the port. It does not disconnect the port.
Parameters:
p_ - the port to be removed from this component.
Returns:
the port.

removePort

public final Port removePort(java.lang.String id_)
Removes the port in the default port group. It does not disconnect the port.
Parameters:
id_ - ID of the port.
Returns:
the port.

setPort

public final void setPort(Port newPort_,
                          java.lang.String groupID_,
                          java.lang.String id_)
Replaces the port, the given group id and the port id, with newPort. It does not disconnect the replaced port.

setPort

public final void setPort(Port newPort_,
                          java.lang.String id_)
Replaces the port in the default port group, given the port id, with newPort. It does not disconnect the replaced port.

addPort

public final Port addPort(Port new_,
                          java.lang.String groupID_,
                          java.lang.String newID_)
Adds a port with the given group id and the port id. It assigns an ID if the given id is null.
Parameters:
new_ - the port to be added to this component.
groupID_ - group ID of the port.
newID_ - ID of the port.
Returns:
new_ or null if port of the same ID in the same group exists.

addPort

public final Port addPort(Port new_,
                          java.lang.String groupID_,
                          java.lang.String newID_,
                          boolean isRemovable_)
Adds a port with the given group id and the port id. It assigns an ID if the given id is null.
Parameters:
new_ - the port to be added to this component.
groupID_ - group ID of the port.
newID_ - ID of the port.
Returns:
new_ or null if port of the same ID in the same group exists.

addPort

public final Port addPort(Port new_,
                          java.lang.String newID_)
Adds a port to the default port group with the given port id, It assigns an ID if the given id is null. If the port already exists, the port is returned.
Parameters:
id_ - ID of the port.
Returns:
the port.

addPort

public final Port addPort(Port new_,
                          java.lang.String newID_,
                          boolean isRemovable_)
Adds a port to the default port group with the given port id, It assigns an ID if the given id is null. If the port already exists, the port is returned.
Parameters:
id_ - ID of the port.
Returns:
the port.

addPort

public final Port addPort(java.lang.String id_)
Creates a port in the default port group with the given port id, It assigns an ID if the given id is null. If the port already exists, the port is returned.
Parameters:
id_ - ID of the port.
Returns:
the port.

addPort

public final Port addPort(java.lang.String id_,
                          boolean isRemovable_)
Creates a port in the default port group with the given port id, It assigns an ID if the given id is null. If the port already exists, the port is returned.
Parameters:
id_ - ID of the port.
Returns:
the port.

addPort

public final Port addPort(java.lang.String groupID_,
                          java.lang.String id_)
Creates a port with the given group id and the port id. It assigns an ID if the given id is null. If the port already exists, the port is returned.
Parameters:
groupID_ - group ID of the port.
id_ - ID of the port.
Returns:
the port.

addPort

public final Port addPort(java.lang.String groupID_,
                          java.lang.String id_,
                          boolean isRemovable_)
Creates a port with the given group id and the port id. It assigns an ID if the given id is null. If the port already exists, the port is returned.
Parameters:
groupID_ - group ID of the port.
id_ - ID of the port.
Returns:
the port.

containsPort

public final boolean containsPort(Port p_)
Returns true if the component owns the port.

isPortRemovable

public final boolean isPortRemovable(Port p_)
Returns true if the port is removable from this component.

setPortRemovable

protected final void setPortRemovable(Port p_,
                                      boolean v_)
Sets the port to be (un)removable.

connect

public boolean connect(Component c_,
                       boolean shared_)
stablishes a two-way connection between this and the specified component. his method uses findAvailable() to get ports from he components for connection. By default, the method returns an vailable port in the default port group. Subclasses should override findAvailable() if should behave otherwise.
Parameters:
shared_ - set to true if both directions of the connection should share the same wire. see Component.findAvailable() see Component.findAvailable(String)

findAvailable

public Port findAvailable()
Returns an unconnected port from the default connection port group of this component. By default, it uses the default port group. Subclasses should override this method if behave otherwise.
See Also:
connect(Component, boolean), findAvailable(String)

findAvailable

public final Port findAvailable(java.lang.String groupID_)
Returns an unconnected port from the specified port group.

findAvailable

public final Port findAvailable(java.lang.String groupID_,
                                java.lang.String portType_)
Returns an unconnected port of the given port type from the specified port group.

exposePort

public Port exposePort(Component child_,
                       java.lang.String pid_)
Creates a port that proxies for the client port, specified by the child component, group id and port id. The method attempts to create the proxy port in the same port group (default group) with the same port id as those of the child port. If failed, it assigns an unused id to the proxy port.

exposePort

public Port exposePort(Component child_,
                       java.lang.String groupID_,
                       java.lang.String id_)
Creates a shadow port for a port of the child component's, specified by the child component, the port group id and the port id. The method attempts to create the shadow port in the same port group with the same port id as those of the port of the child component. If the attempt fails, it assigns an unused id to the shadow port.

exposePort

public Port exposePort(Component child_,
                       java.lang.String groupID_,
                       java.lang.String id_,
                       java.lang.String mygroupID_,
                       java.lang.String myID_)
Creates a shadow port, with the given group id and the port id, for a port of the child component, specified by the child component, the port group id and the port id.

exposePort

public Port exposePort(Port client_)
Creates a shadow port for the client port and makes it have the same group ID and port ID as the client's.

exposePort

public Port exposePort(Port client_,
                       java.lang.String mygroupID_,
                       java.lang.String myID_)
Creates a shadow port, with the given group id and the port id, for the client port.

disconnectAllPeers

public void disconnectAllPeers()
Disconnects this component from the rest of the system. The internal connections remain.

addComponent

public void addComponent(Component c_)
Adds a child component.

addComponent

public void addComponent(Component c_,
                         boolean inheritRuntime_)
Adds a child component.

containsComponent

public boolean containsComponent(Component c_)
Returns true if the specified component is an immediate child of this component.

isAncestorOf

public boolean isAncestorOf(Component c_)
Returns true if the component hierarchy rooted at this component contains the specified component.

containsComponent

public boolean containsComponent(java.lang.String id_)
Returns true if the ID matches one of its child components'.

removeComponent

public Component removeComponent(Component c_)
Removes a child from this component. This method does not disconnect the child component.
Returns:
the removed child component; null if this component does not contain the child.

removeComponent

public Component removeComponent(java.lang.String id_)
Removes a child given the component ID. This method does not disconnect the child component.
Returns:
the removed child component; null if this component does not contain the child.

getAllComponents

public Component[] getAllComponents()
Returns all the child components.

isContainer

public boolean isContainer()
Returns true if this component is a container.

removeAllComponents

public void removeAllComponents()
Removes all the child components. This method does not disconnect the child components.

getComponent

public Component getComponent(java.lang.String id_)
Returns the child given the component I