ninja.activeproxy.path.description
Class PathDescription

java.lang.Object
  |
  +--ninja.activeproxy.path.description.ElementDescription
        |
        +--ninja.activeproxy.path.description.PathDescription

public class PathDescription
extends ElementDescription

Description of a path.

See Also:
Serialized Form

Field Summary
private  java.util.Vector operators
           
private  java.lang.Object pathID
           
 
Fields inherited from class ninja.activeproxy.path.description.ElementDescription
attributes, children, type
 
Constructor Summary
PathDescription()
          Constructs a PathDescription.
 
Method Summary
 void addConnector(ConnectorDescription connector)
          Adds a connector to this path.
 void addConnector(ConnectorDescription connector, int sourcePosition)
          Adds a connector to this path, where the position of the source of the connector is specified.
 void addConnector(ConnectorDescription connector, OperatorDescription source)
          Adds a connector to this path, where the source of the connector is specified.
 void addOperator(OperatorDescription operator)
          Adds an operator to the end of the path.
 void addOperator(OperatorDescription operator, int position)
          Adds an operator at the specified position, shifting every operator in the path.
 void addPath(PathDescription insertedPath, int sourcePosition, int sinkPosition)
          Inserts a path between the operators specified by source and sink positions.
 ConnectorDescription getConnector(int sourcePosition)
          Returns the connector with the source operator at the given position.
 ConnectorDescription getConnector(OperatorDescription source)
          Returns the connector with the given source operator.
 java.util.Vector getConnectors()
          Returns a vector of all connectors in this path.
 int getNumConnectors()
          Return the number of connectors in this path.
 int getNumOperators()
          Returns the number of operators in the path.
 OperatorDescription getOperator(int position)
          Returns the operator at the specified position.
 java.util.Vector getOperators()
          Returns a vector of (ordered) operators in the path.
 java.lang.Object getPathID()
          Returns the path ID for this path.
static PathDescription readDescription(java.lang.String file)
          Creates a path description from the given file.
 java.util.Vector removeAllConnectors()
          Removes all connectors in this path.
 java.util.Vector removeAllOperators()
          Removes all operators in this path.
 ConnectorDescription removeConnector(int sourcePosition)
          Removes connector with source operator at the given position.
 ConnectorDescription removeConnector(OperatorDescription source)
          Removes connector with given source operator.
 OperatorDescription removeOperator(int position)
          Removes the operator at the specified position.
 PathDescription removePath(int sourcePosition, int sinkPosition)
          Removes path between the operators specified by source and sink positions.
 void setConnectors(java.util.Vector connectors)
          Sets the connectors in this path.
 void setOperators(java.util.Vector operators)
          Sets the operators for this path.
 void setPathID(java.lang.Object pathID)
          Set the path ID for this path.
 
Methods inherited from class ninja.activeproxy.path.description.ElementDescription
addChild, addChildren, getAllAttributes, getAttr, getChildren, getChildrenByType, getType, removeChild, removeChildrenByType, setAttr
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

operators

private java.util.Vector operators

pathID

private java.lang.Object pathID
Constructor Detail

PathDescription

public PathDescription()
Constructs a PathDescription.
Method Detail

setPathID

public void setPathID(java.lang.Object pathID)
Set the path ID for this path.
Parameters:
pathID - path ID.

getPathID

public java.lang.Object getPathID()
Returns the path ID for this path.
Returns:
path ID.

setOperators

public void setOperators(java.util.Vector operators)
Sets the operators for this path.
Parameters:
operator - vector of (ordered) operators in the path.

getOperators

public java.util.Vector getOperators()
Returns a vector of (ordered) operators in the path.
Returns:
vector of (ordered) operators in the path.

getNumOperators

public int getNumOperators()
Returns the number of operators in the path.
Returns:
the number of operators in the path.

addOperator

public void addOperator(OperatorDescription operator)
Adds an operator to the end of the path.
Parameters:
operator - operator to be added.

addOperator

public void addOperator(OperatorDescription operator,
                        int position)
                 throws java.lang.ArrayIndexOutOfBoundsException
Adds an operator at the specified position, shifting every operator in the path.
Parameters:
operator - operator to be added.
position - position where to add the opeartor.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid position.

getOperator

public OperatorDescription getOperator(int position)
                                throws java.lang.ArrayIndexOutOfBoundsException
Returns the operator at the specified position.
Parameters:
position - position of the operator to be returned.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid position.

removeAllOperators

public java.util.Vector removeAllOperators()
Removes all operators in this path.
Returns:
a vector of all (ordered) operators removed from the path.

removeOperator

public OperatorDescription removeOperator(int position)
                                   throws java.lang.ArrayIndexOutOfBoundsException
Removes the operator at the specified position.
Parameters:
position - position of the operator to be removed.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid position.

setConnectors

public void setConnectors(java.util.Vector connectors)
Sets the connectors in this path. Removes all previous connectors.
Parameters:
connectors - vector of connectors to be set for this path.

getConnectors

public java.util.Vector getConnectors()
Returns a vector of all connectors in this path.
Returns:
vector of all connectors in this path.

getNumConnectors

public int getNumConnectors()
Return the number of connectors in this path.
Returns:
the number of connectors in this path.

addConnector

public void addConnector(ConnectorDescription connector)
Adds a connector to this path.
Parameters:
connector - connector to be added to this path.

addConnector

public void addConnector(ConnectorDescription connector,
                         OperatorDescription source)
                  throws java.lang.ArrayIndexOutOfBoundsException
Adds a connector to this path, where the source of the connector is specified. No need to specify the destination operator for the connector since this can be inferred from the ordering of the connectors in that path.
Parameters:
connector - connector to be added.
source - source operator for this connector.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid source operator specified.

addConnector

public void addConnector(ConnectorDescription connector,
                         int sourcePosition)
                  throws java.lang.ArrayIndexOutOfBoundsException
Adds a connector to this path, where the position of the source of the connector is specified. No need to specify the destination operator for the connector since this can be inferred from the ordering of the connectors in that path.
Parameters:
connector - connector to be added.
sourcePosition - position of source operator for this connector.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid source operator position specified.

getConnector

public ConnectorDescription getConnector(OperatorDescription source)
                                  throws java.lang.ArrayIndexOutOfBoundsException
Returns the connector with the given source operator.
Parameters:
source - source operator of the connector.
Returns:
connector connector with the given source operator.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid source operator.

getConnector

public ConnectorDescription getConnector(int sourcePosition)
                                  throws java.lang.ArrayIndexOutOfBoundsException
Returns the connector with the source operator at the given position.
Parameters:
sourcePosition - position of source operator of the connector.
Returns:
connector connector with the source operator at the given position.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid position for source operator.

removeAllConnectors

public java.util.Vector removeAllConnectors()
Removes all connectors in this path.
Returns:
vector of all connectors removed.

removeConnector

public ConnectorDescription removeConnector(OperatorDescription source)
                                     throws java.lang.ArrayIndexOutOfBoundsException
Removes connector with given source operator.
Parameters:
source - source operator of connector to be removed.
Returns:
connector removed.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid source operator.

removeConnector

public ConnectorDescription removeConnector(int sourcePosition)
                                     throws java.lang.ArrayIndexOutOfBoundsException
Removes connector with source operator at the given position.
Parameters:
sourcePosition - source operator position of connector to be removed.
Returns:
connector removed.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if invalid source operator position.

addPath

public void addPath(PathDescription insertedPath,
                    int sourcePosition,
                    int sinkPosition)
             throws java.lang.ArrayIndexOutOfBoundsException
Inserts a path between the operators specified by source and sink positions. The first node in the inserted path will come right after the source operator and the sink operator will come right after the last node in the inserted path. All connectors and operators of the inserted path will be inserted into the path. However, there will be no connectors between source operator and first node of inserted path and between last node of inserted path and sink operator. These will have to be inserted separately.
Parameters:
insertedPath - path to be inserted.
sourcePosition - position of source operator.
sinkPosition - position of sink operator.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if source or sink position is invalid.

removePath

public PathDescription removePath(int sourcePosition,
                                  int sinkPosition)
                           throws java.lang.ArrayIndexOutOfBoundsException
Removes path between the operators specified by source and sink positions. After removal the source operator will come right before the sink operator, but no connector will exist between the two.
Parameters:
sourcePosition - position of source operator.
sinkPosition - position of sink operator.
Returns:
path removed, containing operators in the original order and connectors
Throws:
java.lang.ArrayIndexOutOfBoundsException - if source or sink position is invalid.

readDescription

public static PathDescription readDescription(java.lang.String file)
Creates a path description from the given file.
Parameters:
file - file where to read from.
Returns:
a PatDescription created from the file.