org.xmloperator.lambda.net.model
Interface Operator

All Known Subinterfaces:
Abstractor, Applicator, Delimiter, Duplicator, Eraser, IndexedOperator

public interface Operator

Operator node in a lambda-net.

It is either an Eraser, a Delimiter, an Abstractor, an Applicator or a Duplicator.

Each one has a principal Port and may have 1 or 2 auxiliary Ports. By exception, the Eraser has either a principal Port either an auxiliary Port. The principal Port is numbered 0. Auxiliary ports are numbered 1 and 2.

An Operator instance is created by using an OperatorFactory and is terminated by being returned to the same OperatorFactory.

See Also:
OperatorFactory

Field Summary
static int INTERACTION_ANNIHILATE_DELIMITER
           
static int INTERACTION_ANNIHILATE_DUPLICATOR
           
static int INTERACTION_ANNIHILATE_ERASER
           
static int INTERACTION_BETA_IDENTITY
           
static int INTERACTION_BETA_REDUCTION
           
static int INTERACTION_COMMUTE_DELIMITER
           
static int INTERACTION_COMMUTE_DUPLICATOR
           
static int INTERACTION_DUPLICATE_ABSTRACTOR
           
static int INTERACTION_DUPLICATE_APPLICATOR
           
static int INTERACTION_DUPLICATE_IDENTITY
           
static int INTERACTION_ERASE_ABSTRACTOR
           
static int INTERACTION_ERASE_APPLICATOR
           
static int INTERACTION_ERASE_DELIMITER
           
static int INTERACTION_ERASE_DUPLICATOR
           
static int INTERACTION_ERASE_IDENTITY
           
static int INTERACTION_EXTRUDE_ABSTRACTOR
           
static int INTERACTION_EXTRUDE_APPLICATOR
           
static int INTERACTION_EXTRUDE_CLOSED_ABSTRACTOR
           
static int INTERACTION_EXTRUDE_DUPLICATOR
           
static int INTERACTION_EXTRUDE_IDENTITY
           
static int INTERACTION_TYPE_COUNT
           
static java.lang.String[] INTERACTION_TYPE_NAMES
           
static int OPERATOR_TYPE_COUNT
           
static java.lang.String[] OPERATOR_TYPE_NAMES
           
static int TYPE_ABSTRACTOR
           
static int TYPE_APPLICATOR
           
static int TYPE_DELIMITER
           
static int TYPE_DUPLICATOR
           
static int TYPE_ERASER
           
 
Method Summary
 boolean canBeReturnedToFactory()
          Returns true if this can be returned to its factory.
 Operator cloneOperator(boolean isDirectionInversed)
          Creates and return a clone of this Operator.
 OperatorFactory getFactory()
          Returns the factory of this Operator, which can be used for building compatible Operators.
 int getMark()
          Operators can be marked for net traversal.
 int getOperatorType()
          Returns the type of this Operator.
 Port getPort(int number)
          Returns the Port of this Operator, with the given number.
 Port getPort0()
          Returns the principal Port of this Operator or null if it doesn't exist.
 Port getPort1()
          Returns the first auxiliary Port of this Operator or null if it doesn't exist.
 Port getPort2()
          Returns the second auxiliary Port of this Operator or null if it doesn't exist.
 int getPortCount()
          Returns the count of ports of this Operator.
 int interact(ConnectionListener xListener)
          Interacts with the Operator connected on its principal Port.
 boolean isAbstractor()
          Returns true if this Operator is an Abstractor.
 boolean isApplicator()
          Returns true if this Operator is an Applicator.
 boolean isDelimiter()
          Returns true if this Operator is a Delimiter.
 boolean isDirectionInversed()
          Returns true if the direction of this Operator is inversed.
 boolean isDuplicator()
          Returns true if this Operator is a Duplicator.
 boolean isEraser()
          Returns true if this Operator is an Eraser.
 boolean isReturnedToFactory()
          Returns true if this Operator has been returned to the factory.
 void returnToFactory()
          Returns this to its Factory.
 void setMark(int mark)
          Set the mark attached to this operator.
 

Field Detail

OPERATOR_TYPE_COUNT

public static final int OPERATOR_TYPE_COUNT
See Also:
Constant Field Values

TYPE_ERASER

public static final int TYPE_ERASER
See Also:
Constant Field Values

TYPE_DELIMITER

public static final int TYPE_DELIMITER
See Also:
Constant Field Values

TYPE_ABSTRACTOR

public static final int TYPE_ABSTRACTOR
See Also:
Constant Field Values

TYPE_APPLICATOR

public static final int TYPE_APPLICATOR
See Also:
Constant Field Values

TYPE_DUPLICATOR

public static final int TYPE_DUPLICATOR
See Also:
Constant Field Values

OPERATOR_TYPE_NAMES

public static final java.lang.String[] OPERATOR_TYPE_NAMES

INTERACTION_TYPE_COUNT

public static final int INTERACTION_TYPE_COUNT
See Also:
Constant Field Values

INTERACTION_BETA_REDUCTION

public static final int INTERACTION_BETA_REDUCTION
See Also:
Constant Field Values

INTERACTION_BETA_IDENTITY

public static final int INTERACTION_BETA_IDENTITY
See Also:
Constant Field Values

INTERACTION_EXTRUDE_ABSTRACTOR

public static final int INTERACTION_EXTRUDE_ABSTRACTOR
See Also:
Constant Field Values

INTERACTION_EXTRUDE_IDENTITY

public static final int INTERACTION_EXTRUDE_IDENTITY
See Also:
Constant Field Values

INTERACTION_EXTRUDE_CLOSED_ABSTRACTOR

public static final int INTERACTION_EXTRUDE_CLOSED_ABSTRACTOR
See Also:
Constant Field Values

INTERACTION_EXTRUDE_APPLICATOR

public static final int INTERACTION_EXTRUDE_APPLICATOR
See Also:
Constant Field Values

INTERACTION_EXTRUDE_DUPLICATOR

public static final int INTERACTION_EXTRUDE_DUPLICATOR
See Also:
Constant Field Values

INTERACTION_ANNIHILATE_ERASER

public static final int INTERACTION_ANNIHILATE_ERASER
See Also:
Constant Field Values

INTERACTION_ANNIHILATE_DELIMITER

public static final int INTERACTION_ANNIHILATE_DELIMITER
See Also:
Constant Field Values

INTERACTION_ANNIHILATE_DUPLICATOR

public static final int INTERACTION_ANNIHILATE_DUPLICATOR
See Also:
Constant Field Values

INTERACTION_COMMUTE_DELIMITER

public static final int INTERACTION_COMMUTE_DELIMITER
See Also:
Constant Field Values

INTERACTION_COMMUTE_DUPLICATOR

public static final int INTERACTION_COMMUTE_DUPLICATOR
See Also:
Constant Field Values

INTERACTION_DUPLICATE_ABSTRACTOR

public static final int INTERACTION_DUPLICATE_ABSTRACTOR
See Also:
Constant Field Values

INTERACTION_DUPLICATE_IDENTITY

public static final int INTERACTION_DUPLICATE_IDENTITY
See Also:
Constant Field Values

INTERACTION_DUPLICATE_APPLICATOR

public static final int INTERACTION_DUPLICATE_APPLICATOR
See Also:
Constant Field Values

INTERACTION_ERASE_DELIMITER

public static final int INTERACTION_ERASE_DELIMITER
See Also:
Constant Field Values

INTERACTION_ERASE_ABSTRACTOR

public static final int INTERACTION_ERASE_ABSTRACTOR
See Also:
Constant Field Values

INTERACTION_ERASE_IDENTITY

public static final int INTERACTION_ERASE_IDENTITY
See Also:
Constant Field Values

INTERACTION_ERASE_APPLICATOR

public static final int INTERACTION_ERASE_APPLICATOR
See Also:
Constant Field Values

INTERACTION_ERASE_DUPLICATOR

public static final int INTERACTION_ERASE_DUPLICATOR
See Also:
Constant Field Values

INTERACTION_TYPE_NAMES

public static final java.lang.String[] INTERACTION_TYPE_NAMES
Method Detail

getFactory

public OperatorFactory getFactory()
Returns the factory of this Operator, which can be used for building compatible Operators.

Returns:
the factory of this Operator.

isReturnedToFactory

public boolean isReturnedToFactory()
Returns true if this Operator has been returned to the factory.

It must be avoided to keep a reference to an Operator that has been returned to the factory.

This method is the only one that is allowed to call if this Operator has been returned to the factory.

Returns:
true if this Operator has been returned to the factory.

canBeReturnedToFactory

public boolean canBeReturnedToFactory()
Returns true if this can be returned to its factory.

If this is connected then this cannot be returned to factory. It may exist other required conditions for being returnable.

Returns:
true if this can be returned to the factory.

returnToFactory

public void returnToFactory()
Returns this to its Factory.

Pre-condition: this can be returned to the factory.

Post-condition: this is no more usable.

Throws:
java.lang.IllegalStateException - if this cannot be returned to the factory.

getPortCount

public int getPortCount()
Returns the count of ports of this Operator. This is 1 for an Eraser, 2 for a Delimiter, 3 for an Applicator, a Duplicator or an Abstractor.

Returns:
the count of ports of this Operator.

getOperatorType

public int getOperatorType()
Returns the type of this Operator. It is one of the constants TYPE_*.

Returns:
the type of this Operator.

isEraser

public boolean isEraser()
Returns true if this Operator is an Eraser.

Returns:
true if this Operator is an Eraser.

isDelimiter

public boolean isDelimiter()
Returns true if this Operator is a Delimiter.

Returns:
true if this Operator is a Delimiter.

isAbstractor

public boolean isAbstractor()
Returns true if this Operator is an Abstractor.

Returns:
true if this Operator is an Abstractor.

isApplicator

public boolean isApplicator()
Returns true if this Operator is an Applicator.

Returns:
true if this Operator is an Applicator.

isDuplicator

public boolean isDuplicator()
Returns true if this Operator is a Duplicator.

Returns:
true if this Operator is a Duplicator.

getPort

public Port getPort(int number)
Returns the Port of this Operator, with the given number. It may depend on the Operator orientation. Return null if it doesn't exist.

Parameters:
number - the Port number = 0, 1 or 2.
Returns:
the Port of this Operator, with the given number.
Throws:
java.lang.IllegalArgumentException - if the number is neither 0, 1 nor 2.

getPort0

public Port getPort0()
Returns the principal Port of this Operator or null if it doesn't exist. This is a shortcut for getPort(0).

Returns:
the principal Port of this Operator or null if it doesn't exist.

getPort1

public Port getPort1()
Returns the first auxiliary Port of this Operator or null if it doesn't exist. This is a shortcut for getPort(1).

Returns:
the first auxiliary Port of this Operator or null if it doesn't exist.

getPort2

public Port getPort2()
Returns the second auxiliary Port of this Operator or null if it doesn't exist. This is a shortcut for getPort(2).

Returns:
the second auxiliary Port of this Operator or null if it doesn't exist.

getMark

public int getMark()
Operators can be marked for net traversal. Returns the mark attached to this Operator.

Returns:
the mark of this Operator.

setMark

public void setMark(int mark)
Set the mark attached to this operator.

Parameters:
mark - a mark.

isDirectionInversed

public boolean isDirectionInversed()
Returns true if the direction of this Operator is inversed.

Returns:
true if the direction of this Operator is inversed.

cloneOperator

public Operator cloneOperator(boolean isDirectionInversed)
Creates and return a clone of this Operator. Doesn't take current connections into account. The clone is disconnected. Takes the mark into account. The clone will have the same mark.

Parameters:
isDirectionInversed - if true then the the clone Operator direction will be inversed (independently from the ditection of this Operator).
Returns:
the created clone of this Operator.

interact

public int interact(ConnectionListener xListener)
Interacts with the Operator connected on its principal Port. Notify any connection (except beta) between two principal Ports through a ConnectionListener. Returns the conclusion of the interaction.

Pre-conditions:

Post-conditions:

Parameters:
xListener - a ConnectionListener for notifying principal connections other than beta.
Returns:
the report of the interaction : one of the INTERACTION_* constants.
Throws:
java.lang.NullPointerException - if the principal Port is not connected or if the interaction meets a free Port.
org.xmloperator.lambda.net.exception.AuxiliaryPortException - if the connected Port is not a principal Port.
org.xmloperator.lambda.net.exception.MarkedDifferentlyException - if a connected Operator has not the same mark.
org.xmloperator.lambda.net.exception.UnexpectedAnnihilationException - if the interacting Operators are two Abstractors or two Applicators.