DRCL J-Sim API

drcl.comp
Class Util

java.lang.Object
  extended bydrcl.comp.Util

public class Util
extends java.lang.Object

Utilities to manipulate the "path" of a component/port.


Nested Class Summary
static class Util.Link
          The class describes a uni-directional connection between two ports.
 
Field Summary
static java.lang.String BI_ATTACH
           
static java.lang.String BI_CONNECT
           
static java.lang.String FROM_ATTACH
           
static java.lang.String FROM_CONNECT
           
static java.lang.String NO_CONNECT
           
static boolean OPTIMIZED
           
static java.lang.String TO_ATTACH
           
static java.lang.String TO_CONNECT
           
static java.lang.String VERROR_IN
           
static java.lang.String VERROR_IN2
           
static java.lang.String VERROR_INFOPORT
           
static java.lang.String VERROR_INOUT
           
static java.lang.String VERROR_INOUT_IN
           
static java.lang.String VERROR_INOUT_OUT
           
static java.lang.String VERROR_OK
           
static java.lang.String VERROR_OUT
           
static java.lang.String VERROR_OUT2
           
 
Constructor Summary
Util()
           
 
Method Summary
static java.util.Hashtable adjust(java.util.Hashtable topology_, java.lang.Object transparent_)
          Adjusts the explored topology by making the components of the specified class/component transparent.
static java.util.Hashtable adjust(java.util.Hashtable topology_, java.lang.Object[] transparentObjs_, java.lang.Object[] excludedObjs_)
          Adjusts the explored topology by making the components of the specified class/component transparent.
static java.util.Hashtable adjust(java.util.Hashtable topology_, java.lang.Object[] transparentObjs_, java.lang.Object[] excludedObjs_, boolean verbose_)
          Adjusts the explored topology by making the components of the specified class/component transparent.
static java.lang.String checkConnect(Port p1_, Port p2_)
          Checks if two ports are connected and the type of connection if there is any.
static java.lang.String compare(Component c1_, Component c2_)
          Does a structural comparison between two components.
static java.lang.String compare(Port p1_, Port p2_)
          Does a structural comparison between two ports.
static boolean contains(Component container_, Component child_)
          Returns true if the container_ component is an ancester of the child_ component.
static long count(Component root_)
          Returns the number of components inside root_.
static java.util.Hashtable explore(Component[] targets_, java.lang.Object[] transparent_, java.lang.Object[] excluded_, boolean verbose_)
          Explores the topology seen from the specified components in a hierarchical mannger.
static java.util.Hashtable explore(Component target_, java.lang.Object transparent_)
          Explores the topology seen from the specified component in a hierarchical mannger.
static java.util.Hashtable explore(Component target_, java.lang.Object[] transparent_)
          Explores the topology seen from the specified component in a hierarchical mannger.
static java.util.Hashtable explore(Component target_, java.lang.Object[] transparent_, java.lang.Object[] excluded_)
          Explores the topology seen from the specified component in a hierarchical mannger.
static java.util.Hashtable explore(Component target_, java.lang.Object[] transparent_, java.lang.Object[] excluded_, boolean verbose_)
          Explores the topology seen from the specified component in a hierarchical mannger.
static java.util.Hashtable exploreFlat(Component[] targets_, java.lang.Object[] transparent_, java.lang.Object[] excluded_, java.lang.Object[] stop_, boolean verbose_)
          Explores the topology seen from the specified components in a "flat" (as opposed to "hierarchical") mannger.
static java.util.Hashtable exploreFlat(Component target_, java.lang.Object[] transparent_, java.lang.Object[] excluded_, java.lang.Object[] stop_)
          Explores the topology seen from the specified component in a "flat" (as opposed to "hierarchical") mannger.
static java.util.Hashtable exploreFlat(Component target_, java.lang.Object[] transparent_, java.lang.Object[] excluded_, java.lang.Object[] stop_, boolean verbose_)
          Explores the topology seen from the specified component in a "flat" (as opposed to "hierarchical") mannger.
static Component[] getAllComponents(Component root_)
          Returns all components in the component hierarchy, including root_.
static java.lang.String[] getAllPortGroupIDs(Component c_)
          Returns the ID's of all port groups being created in the component.
static java.lang.String getAllProperties(Component c_)
          Returns all the properties of the component.
static java.beans.PropertyDescriptor[] getAllPropertyDescriptors(java.lang.Object c_)
          Returns all the properties of the component/object.
static Wire[] getAllWires(Component root_)
          Returns all wires in the component hierarchy.
static ForkManager getForkManager(Component c_)
          Returns the associated ForkManager of the component.
static java.lang.String getFullID(Component o_)
          Returns the full path of a component.
static java.lang.String getID(Component o_, java.lang.Class stopClass_)
          Returns the partial path of a component starting from the closest ancester that belongs to the given class.
static java.lang.String getID(Component o_, Component stop_)
          Returns the partial path of a component starting from the stop_ ancester.
static Util.Link[] getLinks(Component target_)
          Explores a component's neighbors in a hierarchical mannger.
static Util.Link[] getLinks(Port p_)
          Explores a port's peers in a hierarchical mannger.
static java.lang.String getPortFullID(Port p_)
          Returns the full path of a port.
static java.lang.String getPortFullID(Port p_, boolean type_)
          Returns the full path of a port.
static java.lang.String getPortID(Port p_)
          Returns the canonical form of the port ID.
static java.lang.String getPortID(Port p_, java.lang.Class stopClass_)
          Returns the partial path of a port starting from the closest ancester that belongs to the given class.
static java.lang.String getPortID(Port p_, java.lang.Class stopClass_, boolean type_)
          Returns the partial path of a port starting from the closest ancester that belongs to the given class.
static java.lang.String getPortID(Port p_, Component stop_)
          Returns the partial path of a port starting from the stop_ ancester.
static java.lang.String getPortID(Port p_, Component stop_, boolean type_)
          Returns the partial path of a port starting from the stop_ ancester.
static java.lang.String getProperty(Component c_, java.lang.String pname_)
          Returns the property of the component in String.
static ACARuntime getRuntime(Component c_)
          Returns the associated runtime (ACARuntime) of the component.
static void inject(java.lang.Object data_, java.lang.Object port_)
          Injects data_ at the specified port(s).
static void inject(java.lang.Object data_, java.lang.Object[] ports_)
          Injects data_ at the specified ports.
static Component load(java.io.ObjectInputStream in_)
          Loads a component hierarchy from the ObjectInputStream.
static java.lang.String lockinfo(Component c_)
          Returns the report of the lock information in the component.
static void main(java.lang.String[] args)
          Component property tester.
static java.beans.PropertyDescriptor[] makePropertyDescriptors(java.lang.String[] properties_, java.lang.Class beanClass_, java.lang.Class refClass_)
          Makes the java.beans.PropertyDescriptors for the class.
static void operate(java.lang.Object[] cc_, java.lang.String operation_)
          Starts/stops/resumes components.
static void optimize(Component root_)
           
static Component resolvePath(java.lang.String path_, Component start_)
          Returns the component, given a relative path and the starting component of the path.
static void save(java.io.ObjectOutputStream s_, Component subroot_)
          Saves the component hierarchy with the given root to the ObjectOutputStream.
static Component sClone(Component comp_)
          Returns a clone of this component using object serialization.
static void setForkManager(Component c_, ForkManager fm_)
          Associates the ForkManager to the component.
static void setRuntime(Component c_, ACARuntime m_)
          Associates the runtime (ACARuntime) to the component.
static java.lang.String showConnections(Component c_)
          Returns a report of the connections inside the component.
static java.lang.String showConnections(Component c_, boolean showNoConn_, boolean showType_, boolean showHidden_, boolean showOutside_)
          Returns a report of the connections inside the component.
static java.util.Hashtable verify(Component[] components_, boolean recursive_)
          Verifies the connections inside the specified container component.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTIMIZED

public static boolean OPTIMIZED

BI_CONNECT

public static final java.lang.String BI_CONNECT
See Also:
Constant Field Values

TO_CONNECT

public static final java.lang.String TO_CONNECT
See Also:
Constant Field Values

FROM_CONNECT

public static final java.lang.String FROM_CONNECT
See Also:
Constant Field Values

NO_CONNECT

public static final java.lang.String NO_CONNECT
See Also:
Constant Field Values

BI_ATTACH

public static final java.lang.String BI_ATTACH
See Also:
Constant Field Values

TO_ATTACH

public static final java.lang.String TO_ATTACH
See Also:
Constant Field Values

FROM_ATTACH

public static final java.lang.String FROM_ATTACH
See Also:
Constant Field Values

VERROR_IN

public static final java.lang.String VERROR_IN
See Also:
Constant Field Values

VERROR_IN2

public static final java.lang.String VERROR_IN2
See Also:
Constant Field Values

VERROR_OUT

public static final java.lang.String VERROR_OUT
See Also:
Constant Field Values

VERROR_OUT2

public static final java.lang.String VERROR_OUT2
See Also:
Constant Field Values

VERROR_INOUT_IN

public static final java.lang.String VERROR_INOUT_IN
See Also:
Constant Field Values

VERROR_INOUT_OUT

public static final java.lang.String VERROR_INOUT_OUT
See Also:
Constant Field Values

VERROR_INOUT

public static final java.lang.String VERROR_INOUT
See Also:
Constant Field Values

VERROR_OK

public static final java.lang.String VERROR_OK
See Also:
Constant Field Values

VERROR_INFOPORT

public static final java.lang.String VERROR_INFOPORT
See Also:
Constant Field Values
Constructor Detail

Util

public Util()
Method Detail

getAllPortGroupIDs

public static java.lang.String[] getAllPortGroupIDs(Component c_)
Returns the ID's of all port groups being created in the component.


getFullID

public static java.lang.String getFullID(Component o_)
Returns the full path of a component.


getID

public static java.lang.String getID(Component o_,
                                     Component stop_)
Returns the partial path of a component starting from the stop_ ancester.


getID

public static java.lang.String getID(Component o_,
                                     java.lang.Class stopClass_)
Returns the partial path of a component starting from the closest ancester that belongs to the given class.


getPortFullID

public static java.lang.String getPortFullID(Port p_)
Returns the full path of a port. The port type is not shown.


getPortFullID

public static java.lang.String getPortFullID(Port p_,
                                             boolean type_)
Returns the full path of a port.

Parameters:
type_ - set to true to show the port type.

getPortID

public static java.lang.String getPortID(Port p_,
                                         Component stop_)
Returns the partial path of a port starting from the stop_ ancester. Port name and type are not shown.


getPortID

public static java.lang.String getPortID(Port p_,
                                         Component stop_,
                                         boolean type_)
Returns the partial path of a port starting from the stop_ ancester.

Parameters:
type_ - set to true to show the port type.

getPortID

public static java.lang.String getPortID(Port p_,
                                         java.lang.Class stopClass_)
Returns the partial path of a port starting from the closest ancester that belongs to the given class. The port type is not shown.


getPortID

public static java.lang.String getPortID(Port p_,
                                         java.lang.Class stopClass_,
                                         boolean type_)
Returns the partial path of a port starting from the closest ancester that belongs to the given class.

Parameters:
type_ - set to true to show the port type.

getPortID

public static java.lang.String getPortID(Port p_)
Returns the canonical form of the port ID.


resolvePath

public static Component resolvePath(java.lang.String path_,
                                    Component start_)
Returns the component, given a relative path and the starting component of the path.

Returns:
null if the path is not valid.

compare

public static java.lang.String compare(Component c1_,
                                       Component c2_)
Does a structural comparison between two components. Returns the list of differences.


compare

public static java.lang.String compare(Port p1_,
                                       Port p2_)
Does a structural comparison between two ports. Returns the list of differences.


contains

public static boolean contains(Component container_,
                               Component child_)
Returns true if the container_ component is an ancester of the child_ component.


checkConnect

public static java.lang.String checkConnect(Port p1_,
                                            Port p2_)
Checks if two ports are connected and the type of connection if there is any.

Returns:
combination of the connection result (BI_CONNECT, TO_CONNECT(-->), FROM_CONNECT(<--) or NO_CONNECT) and the attachment result (BI_ATTACH, TO_ATTACH or FROM_ATTACH).

showConnections

public static java.lang.String showConnections(Component c_)
Returns a report of the connections inside the component. The report also includes unconnected ports, port type, hidden ports and connections that go outside of the component.


showConnections

public static java.lang.String showConnections(Component c_,
                                               boolean showNoConn_,
                                               boolean showType_,
                                               boolean showHidden_,
                                               boolean showOutside_)
Returns a report of the connections inside the component.

Parameters:
showNoConn_ - set to true to include unconnected ports in the report.
showType_ - set to true to include port type in the report.
showHidden_ - set to true to include hidden ports in the report.
showOutside_ - set to true to include connections that go outside of the component.

sClone

public static Component sClone(Component comp_)
Returns a clone of this component using object serialization.


save

public static void save(java.io.ObjectOutputStream s_,
                        Component subroot_)
Saves the component hierarchy with the given root to the ObjectOutputStream. using object serialization.


load

public static Component load(java.io.ObjectInputStream in_)
Loads a component hierarchy from the ObjectInputStream. Returns the root component of the hierarchy.


setRuntime

public static void setRuntime(Component c_,
                              ACARuntime m_)
Associates the runtime (ACARuntime) to the component.


getRuntime

public static ACARuntime getRuntime(Component c_)
Returns the associated runtime (ACARuntime) of the component.


setForkManager

public static void setForkManager(Component c_,
                                  ForkManager fm_)
Associates the ForkManager to the component.


getForkManager

public static ForkManager getForkManager(Component c_)
Returns the associated ForkManager of the component.


operate

public static void operate(java.lang.Object[] cc_,
                           java.lang.String operation_)
Starts/stops/resumes components. The method stops the associated runtime(s) before operating the components and resumes the runtime(s) afterwards. It eliminates randomness between the (current) process of operating the components and the processes of operated components.


inject

public static void inject(java.lang.Object data_,
                          java.lang.Object[] ports_)
Injects data_ at the specified ports.


inject

public static void inject(java.lang.Object data_,
                          java.lang.Object port_)
Injects data_ at the specified port(s).


verify

public static java.util.Hashtable verify(Component[] components_,
                                         boolean recursive_)
Verifies the connections inside the specified container component. Returns a hashtable with port as key and error message as result.


getLinks

public static Util.Link[] getLinks(Port p_)
Explores a port's peers in a hierarchical mannger. Returns all the connections (in an array of {$link Link}s} emerged from the specified port.


getLinks

public static Util.Link[] getLinks(Component target_)
Explores a component's neighbors in a hierarchical mannger. Returns all the connections (in an array of {$link Link}s} emerged from the specified port. public static Link[] getLinks(Component target_) { Port[] pp_ = target_.getAllPorts(); Link[][] lll_ = new Link[pp_.length][]; int n_ = 0; for (int i=0; i

explore

public static java.util.Hashtable explore(Component target_,
                                          java.lang.Object transparent_)
Explores the topology seen from the specified component in a hierarchical mannger.

Parameters:
target_ - the specified component.
transparent_ - class/component to be transparent during exploration.
Returns:
a hashtable which maps a component to its connections (Util.Link[]).

explore

public static java.util.Hashtable explore(Component target_,
                                          java.lang.Object[] transparent_)
Explores the topology seen from the specified component in a hierarchical mannger.

Parameters:
target_ - the specified component.
transparent_ - array of classes/components to be transparent during exploration.
Returns:
a hashtable which maps a component to its connections (Util.Link[]).

explore

public static java.util.Hashtable explore(Component target_,
                                          java.lang.Object[] transparent_,
                                          java.lang.Object[] excluded_)
Explores the topology seen from the specified component in a hierarchical mannger.

Parameters:
target_ - the specified component.
transparent_ - array of classes to be transparent during exploration.
excluded_ - is the array of classes to be excluded.
Returns:
a hashtable which maps a component to its connections (Link[]).

explore

public static java.util.Hashtable explore(Component target_,
                                          java.lang.Object[] transparent_,
                                          java.lang.Object[] excluded_,
                                          boolean verbose_)
Explores the topology seen from the specified component in a hierarchical mannger.

Parameters:
target_ - the specified component.
transparent_ - array of classes to be transparent during exploration.
excluded_ - is the array of classes to be excluded.
Returns:
a hashtable which maps a component to its connections (Link[]).

explore

public static java.util.Hashtable explore(Component[] targets_,
                                          java.lang.Object[] transparent_,
                                          java.lang.Object[] excluded_,
                                          boolean verbose_)
Explores the topology seen from the specified components in a hierarchical mannger.

Parameters:
targets_ - the specified components.
transparent_ - array of classes to be transparent during exploration.
excluded_ - is the array of classes to be excluded.
Returns:
a hashtable which maps a component to its connections (Link[]).

exploreFlat

public static java.util.Hashtable exploreFlat(Component target_,
                                              java.lang.Object[] transparent_,
                                              java.lang.Object[] excluded_,
                                              java.lang.Object[] stop_)
Explores the topology seen from the specified component in a "flat" (as opposed to "hierarchical") mannger.

Parameters:
target_ - the specified component.
transparent_ - array of classes to be transparent during exploration.
excluded_ - is the array of classes to be excluded.
stop_ - components that are not further explored inside.
Returns:
a hashtable which maps a component to its connections (Link[]).

exploreFlat

public static java.util.Hashtable exploreFlat(Component target_,
                                              java.lang.Object[] transparent_,
                                              java.lang.Object[] excluded_,
                                              java.lang.Object[] stop_,
                                              boolean verbose_)
Explores the topology seen from the specified component in a "flat" (as opposed to "hierarchical") mannger.

Parameters:
target_ - the specified component.
transparent_ - array of classes to be transparent during exploration.
excluded_ - is the array of classes to be excluded.
stop_ - components that are not further explored inside.
Returns:
a hashtable which maps a component to its connections (Link[]).

exploreFlat

public static java.util.Hashtable exploreFlat(Component[] targets_,
                                              java.lang.Object[] transparent_,
                                              java.lang.Object[] excluded_,
                                              java.lang.Object[] stop_,
                                              boolean verbose_)
Explores the topology seen from the specified components in a "flat" (as opposed to "hierarchical") mannger.

Parameters:
targets_ - the specified components.
transparent_ - array of classes to be transparent during exploration.
excluded_ - is the array of classes to be excluded.
stop_ - components that are not further explored inside.
Returns:
a hashtable which maps a component to its connections (Link[]).

adjust

public static java.util.Hashtable adjust(java.util.Hashtable topology_,
                                         java.lang.Object transparent_)
Adjusts the explored topology by making the components of the specified class/component transparent.

Parameters:
topology_ - is a hashtable mapping from a component to Util.Link[].
transparent_ - is the class/component to be treated transparently.
Returns:
the new topology.

adjust

public static java.util.Hashtable adjust(java.util.Hashtable topology_,
                                         java.lang.Object[] transparentObjs_,
                                         java.lang.Object[] excludedObjs_)
Adjusts the explored topology by making the components of the specified class/component transparent.

Parameters:
topology_ - is a hashtable mapping from a component to Util.Link[].
transparentObjs_ - is the array of classes to be treated transparently.
excludedObjs_ - is the array of classes/components to be excluded.
Returns:
the new topology.

adjust

public static java.util.Hashtable adjust(java.util.Hashtable topology_,
                                         java.lang.Object[] transparentObjs_,
                                         java.lang.Object[] excludedObjs_,
                                         boolean verbose_)
Adjusts the explored topology by making the components of the specified class/component transparent.

Parameters:
topology_ - is a hashtable mapping from a component to Util.Link[].
transparentObjs_ - is the array of classes to be treated transparently.
excludedObjs_ - is the array of classes/components to be excluded.
Returns:
the new topology.

lockinfo

public static java.lang.String lockinfo(Component c_)
Returns the report of the lock information in the component.


getAllProperties

public static java.lang.String getAllProperties(Component c_)
Returns all the properties of the component.


getAllPropertyDescriptors

public static java.beans.PropertyDescriptor[] getAllPropertyDescriptors(java.lang.Object c_)
Returns all the properties of the component/object.


getProperty

public static java.lang.String getProperty(Component c_,
                                           java.lang.String pname_)
Returns the property of the component in String.


makePropertyDescriptors

public static java.beans.PropertyDescriptor[] makePropertyDescriptors(java.lang.String[] properties_,
                                                                      java.lang.Class beanClass_,
                                                                      java.lang.Class refClass_)
Makes the java.beans.PropertyDescriptors for the class.


count

public static long count(Component root_)
Returns the number of components inside root_.


optimize

public static void optimize(Component root_)

getAllWires

public static Wire[] getAllWires(Component root_)
Returns all wires in the component hierarchy.


getAllComponents

public static Component[] getAllComponents(Component root_)
Returns all components in the component hierarchy, including root_.


main

public static void main(java.lang.String[] args)
Component property tester. Given component class and the property name, it returns the default value of the property in String.


DRCL J-Sim API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~