cz.cuni.jagrlib
Class BasicPlug

java.lang.Object
  extended by cz.cuni.jagrlib.BasicPlug
All Implemented Interfaces:
Plug

public class BasicPlug
extends java.lang.Object
implements Plug

Basic Plug implementation - can be used for internal Plugs - inside executed Composition.

Since:
0.04
See Also:
BasicPlug.java, Plug, Piece, Channel

Field Summary
protected  boolean cloneable
          Is that Plug cloneable (=generic)?
protected  java.lang.String inputInterface
          Fully qualified input interface name (implemented interface).
protected  java.lang.String key
          Key string used in associated Template.
protected  boolean mandatory
          Is that Plug mandatory?
protected  boolean multi
          Can that Plug be used in multi-channels?
protected  java.lang.String outputInterface
          Fully qualified output interface name (required interface).
protected  Template template
          Associated Template.
 
Constructor Summary
BasicPlug(boolean _mandatory, boolean _multi, boolean _cloneable, java.lang.String _inputInterface, java.lang.String _outputInterface, Template _template, java.lang.String _key)
          Assign constructor - initializes a new BasicPlug object.
 
Method Summary
 void connectChannel(Channel channel)
          Connects the Channel in the associated Piece.
 boolean disconnectChannel()
          Disconnects the associated channel.
 java.lang.Object getInputInterface()
          Returns the internal (implemented) interface object - to be called from outside.
 java.lang.String getInputInterfaceName()
          Returns the fully-qualified name of an internal (implemented) interface - to be called from outside.
 java.lang.String getKey()
          Gets the access key from associated Template to this Plug.
 java.lang.String getOutputInterfaceName()
          Returns the fully-qualified name of an external (required) interface - to be called from this Piece.
 Piece getPiece()
          Gets the associated Piece.
 Template getTemplate()
          Gets the associated Template.
 boolean isCloneable()
          Can this Plug be cloned?
 boolean isCompatible(Plug pl)
          Compatibility test: Am I compatible with the given Plug?
 boolean isCompatible(java.lang.String iInterface, java.lang.String oInterface, boolean cl, boolean mul)
          Compatibility test: Am I compatible with the given parameters?
 boolean isInput()
          Has this Plug the input capability (can be called from outside)?
 boolean isMandatory()
          Is this Plug mandatory?
 boolean isMulti()
          Can this Plug be used in multi-channels?
 boolean isOpposite(Plug opposite)
          Compatibility test: Am I compatible with the opposite Plug?
 boolean isOutput()
          Has this Plug the output capability (can call other interfaces)?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mandatory

protected boolean mandatory
Is that Plug mandatory?


multi

protected boolean multi
Can that Plug be used in multi-channels?

See Also:
Channel

cloneable

protected boolean cloneable
Is that Plug cloneable (=generic)?

See Also:
key

inputInterface

protected java.lang.String inputInterface
Fully qualified input interface name (implemented interface).


outputInterface

protected java.lang.String outputInterface
Fully qualified output interface name (required interface).


template

protected Template template
Associated Template.

See Also:
key

key

protected java.lang.String key
Key string used in associated Template.

See Also:
template
Constructor Detail

BasicPlug

public BasicPlug(boolean _mandatory,
                 boolean _multi,
                 boolean _cloneable,
                 java.lang.String _inputInterface,
                 java.lang.String _outputInterface,
                 Template _template,
                 java.lang.String _key)
Assign constructor - initializes a new BasicPlug object.

Parameters:
_mandatory - Is that plug mandatory (has to be connected)?
_multi - Can that plug be used in multi-channels?
_cloneable - Is that plug "cloneable" (=generic)? If yes, ordinal numbers (starting from 0) will be appended to its name.
_inputInterface - Fully qualified identifier of input (implemented) interface.
_outputInterface - Fully qualified identifier of output (required) interface.
_template - Template this plug is to be associated with.
_key - Key used in associated Template.
Method Detail

isInput

public boolean isInput()
Has this Plug the input capability (can be called from outside)?

Specified by:
isInput in interface Plug
Returns:
true if this Plug can be called from outside.
See Also:
getInputInterfaceName(), getInputInterface()

isOutput

public boolean isOutput()
Has this Plug the output capability (can call other interfaces)?

Specified by:
isOutput in interface Plug
Returns:
true if this Plug can call other interfaces.
See Also:
getOutputInterfaceName()

isMandatory

public boolean isMandatory()
Is this Plug mandatory?

Specified by:
isMandatory in interface Plug
Returns:
true if this Plug is mandatory (has to be connected).

isMulti

public boolean isMulti()
Can this Plug be used in multi-channels?

Specified by:
isMulti in interface Plug
Returns:
true if this Plug can be connected to multi-channel.

isCloneable

public boolean isCloneable()
Can this Plug be cloned? For filters with variable number of (input) channels.
Sibling channels should have access keys with common prefix - integer numbers starting from 0 will be appended.

Specified by:
isCloneable in interface Plug
Returns:
true if this Plug can be cloned.
See Also:
getKey()

getInputInterfaceName

public java.lang.String getInputInterfaceName()
Returns the fully-qualified name of an internal (implemented) interface - to be called from outside.

Specified by:
getInputInterfaceName in interface Plug
Returns:
Fully-qualified name of the interface or null if it is not used.
See Also:
isInput()

getOutputInterfaceName

public java.lang.String getOutputInterfaceName()
Returns the fully-qualified name of an external (required) interface - to be called from this Piece.

Specified by:
getOutputInterfaceName in interface Plug
Returns:
Fully-qualified name of the interface or null if it is not used.
See Also:
isOutput()

getInputInterface

public java.lang.Object getInputInterface()
Returns the internal (implemented) interface object - to be called from outside.

Specified by:
getInputInterface in interface Plug
Returns:
The internal (implemented) interface object or null.

getTemplate

public Template getTemplate()
Gets the associated Template. For topological purposes only.

Specified by:
getTemplate in interface Plug
Returns:
The associated Template or null.
See Also:
getKey()

getPiece

public Piece getPiece()
Gets the associated Piece. For topological purposes only.

Specified by:
getPiece in interface Plug
Returns:
The associated Piece or null.
See Also:
getKey()

getKey

public java.lang.String getKey()
Gets the access key from associated Template to this Plug. For topological purposes only.

Specified by:
getKey in interface Plug
Returns:
The access key or null.
See Also:
getTemplate()

isCompatible

public boolean isCompatible(java.lang.String iInterface,
                            java.lang.String oInterface,
                            boolean cl,
                            boolean mul)
Compatibility test: Am I compatible with the given parameters?

Specified by:
isCompatible in interface Plug
Parameters:
iInterface - Required input interface (or null).
oInterface - Required output interface (or null).
cl - Is the cloneability required?.
mul - Is the multi-channel property required?.
Returns:
true if I'm able to implement the given interface.

isCompatible

public boolean isCompatible(Plug pl)
Compatibility test: Am I compatible with the given Plug?

Specified by:
isCompatible in interface Plug
Parameters:
pl - The checked Plug.
Returns:
true if I'm comptible with the given Plug.

isOpposite

public boolean isOpposite(Plug opposite)
Compatibility test: Am I compatible with the opposite Plug?

Specified by:
isOpposite in interface Plug
Parameters:
opposite - The opposite Plug.
Returns:
true if I'm compatible with the opposite Plug.

connectChannel

public void connectChannel(Channel channel)
Connects the Channel in the associated Piece.

Specified by:
connectChannel in interface Plug
Parameters:
channel - The Channel to be connected to this Plug.

disconnectChannel

public boolean disconnectChannel()
Disconnects the associated channel.

Specified by:
disconnectChannel in interface Plug
Returns:
true if there was a Channel connected.