net.spy.util
Class AbstractSPNode<T extends SPNode<T>>

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.util.AbstractSPNode<T>
All Implemented Interfaces:
Comparable<T>, SPNode<T>

public abstract class AbstractSPNode<T extends SPNode<T>>
extends SpyObject
implements SPNode<T>

Abstract implementation of SPNode to make implementation a bit easier.


Constructor Summary
protected AbstractSPNode()
          Get an instance of AbstractSPNode.
protected AbstractSPNode(SortedSet<SPVertex<T>> l)
          Get an instance of AbstractSPNode holding its links in the given Set.
 
Method Summary
 void addNextHop(SPNode<T> n, SPVertex<T> v)
          Add a vertex to the next hop database to take you to a particular location.
 void clearNextHops()
          Clear out the next hop map.
 boolean equals(Object o)
          Object.equals must be overridden to return results consistent to compareTo(other).
 SortedSet<SPVertex<T>> getConnections()
          Get all of the connections to other nodes.
 SPVertex<T> getNextHop(SPNode<T> n)
          Get the next hop to take you to the given node.
 Map<SPNode<T>,SPVertex<T>> getNextHops()
          Get the mapping of SPNode -> SPVertex hops for this SPNode.
abstract  int hashCode()
          Must override hashCode along with compareTo();
protected  void linkTo(T n)
          Link this SPNode to the given SPNode at the default cost.
protected  void linkTo(T n, int cost)
          Link this SPNode to the given SPNode at the given cost.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

AbstractSPNode

protected AbstractSPNode(SortedSet<SPVertex<T>> l)
Get an instance of AbstractSPNode holding its links in the given Set.

Parameters:
l - the links.

AbstractSPNode

protected AbstractSPNode()
Get an instance of AbstractSPNode.

Method Detail

linkTo

protected void linkTo(T n,
                      int cost)
Link this SPNode to the given SPNode at the given cost.

Parameters:
n - SPNode to which to link
cost - cost of this link

linkTo

protected void linkTo(T n)
Link this SPNode to the given SPNode at the default cost.

Parameters:
n - the node to which to link

getConnections

public SortedSet<SPVertex<T>> getConnections()
Description copied from interface: SPNode
Get all of the connections to other nodes.

Specified by:
getConnections in interface SPNode<T extends SPNode<T>>
Returns:
a SortedSet of SPVertex objects.
See Also:
SPNode

getNextHops

public Map<SPNode<T>,SPVertex<T>> getNextHops()
Description copied from interface: SPNode
Get the mapping of SPNode -> SPVertex hops for this SPNode.

Specified by:
getNextHops in interface SPNode<T extends SPNode<T>>
Returns:
an unmodifiable Map representing mapping
See Also:
SPNode

clearNextHops

public void clearNextHops()
Description copied from interface: SPNode
Clear out the next hop map. This should only be called by an ShortestPathFinder.

Specified by:
clearNextHops in interface SPNode<T extends SPNode<T>>
See Also:
SPNode

getNextHop

public SPVertex<T> getNextHop(SPNode<T> n)
Description copied from interface: SPNode
Get the next hop to take you to the given node.

Specified by:
getNextHop in interface SPNode<T extends SPNode<T>>
Parameters:
n - the node you want to get to
Returns:
the vertex describing the next hop, or null if there's no route to the given node
See Also:
SPNode

addNextHop

public void addNextHop(SPNode<T> n,
                       SPVertex<T> v)
Description copied from interface: SPNode
Add a vertex to the next hop database to take you to a particular location. This is used just for routing information, not normal links. This should only be called by a ShortestPathFinder.

Specified by:
addNextHop in interface SPNode<T extends SPNode<T>>
Parameters:
n - the destination node
v - the vertex that will take you there
See Also:
SPNode

equals

public boolean equals(Object o)
Description copied from interface: SPNode
Object.equals must be overridden to return results consistent to compareTo(other).

Specified by:
equals in interface SPNode<T extends SPNode<T>>
Overrides:
equals in class Object
Parameters:
o - the object to which to compare
Returns:
true if the objects are equal
See Also:
Object

hashCode

public abstract int hashCode()
Must override hashCode along with compareTo();

Specified by:
hashCode in interface SPNode<T extends SPNode<T>>
Overrides:
hashCode in class Object


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.