Package casa.lepton.console
Class OppNetProxy
java.lang.Object
casa.lepton.console.OppNetProxy
- All Implemented Interfaces:
OppNet
,OppNetEventsSource
Class implementing the
OppNet
methods by sending requests
to a OppNetConsole
through a TCP session.-
Field Summary
Fields inherited from interface casa.lepton.OppNet
EDGE_ADDED, EDGE_CHANGED, EDGE_REMOVED, NODE_ADDED, NODE_MOVED, NODE_REMOVED
-
Constructor Summary
ConstructorDescriptionOppNetProxy
(String host, int port) Opens a socket with theOppNetConsole
waiting on the given host/port -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectivityType
(String nodeId, String connectivityType) Add a new connectivity type for the node and update edges accordingly.void
addEdgeListener
(String nodeId, String connectivityType, OppEdgeListener listener) Add a new listener interested in edge events for the given node.void
addEdgeListener
(String nodeId, String connectivityType, String status, OppEdgeListener listener) void
Add a new node in the OppNet.void
addNodeListener
(String nodeId, OppNodeListener listener) Add a new listener interested in node events for a specific node.boolean
areNeighbors
(String nodeId1, String nodeId2, String connectivityType, String edgeStatus) Returns true if there is an edge with the node for the given connectivity type and status.void
close()
Close all opened resources.void
deleteNode
(String nodeId) Remove a node from the OppNet.getEdgeStatus
(String nodeId1, String nodeId2, String connectivityType) Give the status of an edge charaterized by the nodes' ids and the connectivity type.Give the label of the nodegetNeighbors
(String nodeId, String connectivityType, String edgeStatus) Give the neighbors' ids of the node for a given connectivity type and status.getNodes()
Give the nodes in the OppNet.getNodeStatus
(String nodeId, String connectivityType) Give the status of a node for a given connectivity type.Give the tag of the node.boolean
Check whether the node exists in the OppNet.boolean
Give the on/offline status of the node.makeEdgeId
(String id1, String id2, String connectivityType) Give a unique edge id from the given nodes ids and connectivityType in the form "idA-idB:type" where idA = min(id1,id2) and idB = max(id1,id2).int
nbNeighbors
(String nodeId, String connectivityType, String edgeStatus) Returns the number of neighbors of the node for the given connectivity type and status.void
removeConnectivityType
(String nodeId, String connectivityType) Remove a connectivity type for the node and update edges accordingly.void
removeEdgeListener
(String nodeId, String connectivityType) Remove a listener interested in edge events for the given node.void
removeEdgeListener
(String nodeId, String connectivityType, String status) void
removeNodeListener
(String nodeId) Remove a listener interested in node events.boolean
setEdgeStatus
(String nodeId1, String nodeId2, String connectivityType, String status) Change the status of an edge charaterized by the nodes' ids and the connectivity type.void
Change the label of the nodevoid
setNodeStatus
(String nodeId, String connectivityType, String status) Change the status of a node for a given connectivity type.void
Change the on/offline status of the node and update edges accordingly.void
Set the given tag to the node.
-
Constructor Details
-
OppNetProxy
Opens a socket with theOppNetConsole
waiting on the given host/port- Parameters:
host
- the name of the console hostport
- the console TCP port number- Throws:
IOException
-
-
Method Details
-
close
public void close()Close all opened resources. -
addNode
Add a new node in the OppNet. -
deleteNode
Remove a node from the OppNet.- Specified by:
deleteNode
in interfaceOppNet
- Parameters:
nodeId
- the id of the node to be deleted.
-
isNode
Check whether the node exists in the OppNet. -
getNodes
Give the nodes in the OppNet. -
setOnline
Change the on/offline status of the node and update edges accordingly. -
isOnline
Give the on/offline status of the node. -
setLabel
Change the label of the node -
getLabel
Give the label of the node -
setTag
Set the given tag to the node. -
getTag
Give the tag of the node. -
addConnectivityType
Add a new connectivity type for the node and update edges accordingly.- Specified by:
addConnectivityType
in interfaceOppNet
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type to be added to this node.
-
removeConnectivityType
Remove a connectivity type for the node and update edges accordingly.- Specified by:
removeConnectivityType
in interfaceOppNet
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type to be removed from this node.
-
setNodeStatus
Change the status of a node for a given connectivity type.- Specified by:
setNodeStatus
in interfaceOppNet
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type.status
- the new status.
-
getNodeStatus
Give the status of a node for a given connectivity type.- Specified by:
getNodeStatus
in interfaceOppNet
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type.- Returns:
- the status for this node and connectivity type.
-
setEdgeStatus
public boolean setEdgeStatus(String nodeId1, String nodeId2, String connectivityType, String status) Change the status of an edge charaterized by the nodes' ids and the connectivity type. If the edge does not exist, do nothing and change the status of nodes accordingly.- Specified by:
setEdgeStatus
in interfaceOppNet
- Parameters:
nodeId1
- a node id.nodeId2
- another node id.connectivityType
- a connectivity type.status
- the new edge status.- Returns:
- true if the status has been changed.
-
getEdgeStatus
Give the status of an edge charaterized by the nodes' ids and the connectivity type. If the edge does not exist, return null- Specified by:
getEdgeStatus
in interfaceOppNet
- Parameters:
nodeId1
- a node id.nodeId2
- another node id.connectivityType
- a connectivity type.- Returns:
- the edge status
-
getNeighbors
Give the neighbors' ids of the node for a given connectivity type and status. If connectivityType is null, give all neighbors for any connectivity type. If status is null, give all neighbors for any status.- Specified by:
getNeighbors
in interfaceOppNet
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type. May be null.edgeStatus
- an edge status. May be null.- Returns:
- ids of nodes having edges with the given status and connectivity type.
-
nbNeighbors
Returns the number of neighbors of the node for the given connectivity type and status. If connectivityType is null, returns the number of neighbors for any connectivity type. If status is null, returns the number of neighbors whatever the connectivity status.- Specified by:
nbNeighbors
in interfaceOppNet
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type. May be null.edgeStatus
- an edge status. May be null.- Returns:
- return true if the nodes have an edge having the given status and connectivity type.
-
areNeighbors
public boolean areNeighbors(String nodeId1, String nodeId2, String connectivityType, String edgeStatus) Returns true if there is an edge with the node for the given connectivity type and status. If connectivityType is null, return true if there is an edge for any connectivity type. If status is null, give all neighbors for any status.- Specified by:
areNeighbors
in interfaceOppNet
- Parameters:
nodeId1
- a node id.nodeId2
- another node id.connectivityType
- a connectivity type. May be null.edgeStatus
- an edge status. May be null.- Returns:
- return true if the nodes have an edge having the given status and connectivity type.
-
makeEdgeId
Give a unique edge id from the given nodes ids and connectivityType in the form "idA-idB:type" where idA = min(id1,id2) and idB = max(id1,id2).- Specified by:
makeEdgeId
in interfaceOppNet
- Parameters:
id1
- a node id.id2
- other node id.connectivityType
- the connectivity type.- Returns:
- unique edge id.
-
addEdgeListener
Add a new listener interested in edge events for the given node.- Specified by:
addEdgeListener
in interfaceOppNetEventsSource
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type.listener
- the new listener.
-
addEdgeListener
public void addEdgeListener(String nodeId, String connectivityType, String status, OppEdgeListener listener) -
removeEdgeListener
Remove a listener interested in edge events for the given node.- Specified by:
removeEdgeListener
in interfaceOppNetEventsSource
- Parameters:
nodeId
- a node id.connectivityType
- a connectivity type.
-
removeEdgeListener
-
addNodeListener
Add a new listener interested in node events for a specific node.- Specified by:
addNodeListener
in interfaceOppNetEventsSource
- Parameters:
nodeId
- a node id.listener
- the new listener.
-
removeNodeListener
Remove a listener interested in node events.- Specified by:
removeNodeListener
in interfaceOppNetEventsSource
- Parameters:
nodeId
- a node id.
-