org.xmloperator.lambda.net.model
Interface PortStack

All Superinterfaces:
ConnectionListener

public interface PortStack
extends ConnectionListener

Stack of Port. As a ConnectionListener, it keeps only the trace of principal, non beta, connections.


Method Summary
 void clear()
          Clear the content of this stack.
 boolean contains(Port port)
          Returns true if this stack contains the given Port.
 Port get(int index)
          Return the Port at a given root relative index in the stack.
 int getSize()
          Returns the size of the stack.
 boolean isEmpty()
          Returns true if the stack is empty.
 Port pop()
          Return the Port at the top and pop the stack.
 void push(Port port)
          Push a Port on the top of the stack.
 boolean remove(Port port)
          Removes a Port from this stack.
 void replace(int index, Port port)
          Replace the Port at a given root relative index in the stack.
 void returnToFactory()
          Return this PortStack to the Factory.
 Port top()
          Return the Port at the top or null is the stack is empty.
 
Methods inherited from interface org.xmloperator.lambda.net.model.ConnectionListener
notifyConnection
 

Method Detail

returnToFactory

public void returnToFactory()
Return this PortStack to the Factory.

Post-condition: this is no more usable.


getSize

public int getSize()
Returns the size of the stack.

Returns:
the size of the stack.

isEmpty

public boolean isEmpty()
Returns true if the stack is empty.

Returns:
true if the stack is empty.

clear

public void clear()
Clear the content of this stack.


push

public void push(Port port)
Push a Port on the top of the stack.

Parameters:
port - a Port to push.
Throws:
java.lang.IllegalArgumentException - if the given Port is null.

pop

public Port pop()
Return the Port at the top and pop the stack.

Returns:
the Port at the top and pop the stack.
Throws:
java.lang.IllegalStateException - if this stack is empty.

top

public Port top()
Return the Port at the top or null is the stack is empty.

Returns:
the Port at the top or null if the stack is empty.

get

public Port get(int index)
Return the Port at a given root relative index in the stack. get(size - 1) is equivalent to top().

Parameters:
index - an index in the stack, between 0 and size - 1.
Returns:
the Port at the index position.
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 or index >= size.

replace

public void replace(int index,
                    Port port)
Replace the Port at a given root relative index in the stack.

Parameters:
index - an index in the stack, between 0 and size - 1.
port - a Port for replacing the Port actually at the given index.
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 or index >= size.

contains

public boolean contains(Port port)
Returns true if this stack contains the given Port.

Parameters:
port - a Port.
Returns:
true if this stack contains the given Port.

remove

public boolean remove(Port port)
Removes a Port from this stack.

Parameters:
port - a Port.
Returns:
true if the Port has been effectively removed.