Fairness.Nodes.NodeBehaviors
Class SimpleNodeBehavior

java.lang.Object
  extended by Fairness.Nodes.NodeBehaviors.SimpleNodeBehavior
All Implemented Interfaces:
NodeBehavior
Direct Known Subclasses:
RefuseForwardBehavior

public class SimpleNodeBehavior
extends java.lang.Object
implements NodeBehavior

SimpleNodeBehavior is a NodeBehavior that always accepts children, always allows forwarding, and does nothing in receivePacket. This implements a normal node with no freeloader detection.


Constructor Summary
SimpleNodeBehavior()
           
 
Method Summary
 boolean allowChild(Node myNode, Node candidateChild)
          Asks the node behavior if the given Node is allowed to be a child of the Node this behavior is for.
 boolean allowForward(Node myNode, Node target)
          Returns true if this node behavior is currently allowing the Node to send to the given target.
 java.lang.Double getConfidence(Node n)
          Returns this behavior's confidence of the given Node, or null if there is no opinion.
 java.lang.Double getDebtLevel(Node n)
          Returns this behavior's debt level measurement of the given Node, or null if there is no opinion.
 boolean hasConfidenceInformation()
          Returns true if this behavior has confidence information on any Node
 boolean hasDebtLevelInformation()
          Returns true if this behavior has debt levels for any Node
 void receivedPacket(Node myNode, NodePacket packet)
          Event to the node behavior for when a packet is received by the Node.
 void sentPacket(Node myNode, Node destination, NodePacket packet)
          Event called when a Node sends a packet to a child.
 void setParameter(java.lang.String param)
          Allows setting of a single behavior-specific parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleNodeBehavior

public SimpleNodeBehavior()
Method Detail

setParameter

public void setParameter(java.lang.String param)
Allows setting of a single behavior-specific parameter.

Specified by:
setParameter in interface NodeBehavior
Parameters:
param - non-null String

allowChild

public boolean allowChild(Node myNode,
                          Node candidateChild)
Asks the node behavior if the given Node is allowed to be a child of the Node this behavior is for.

Specified by:
allowChild in interface NodeBehavior
Parameters:
myNode - non-null Node to which this behavior belongs.
candidateChild - non-null Node that is not equal to myNode.
Returns:
true if the child can be added, or false otherwise.

allowForward

public boolean allowForward(Node myNode,
                            Node target)
Returns true if this node behavior is currently allowing the Node to send to the given target.

Specified by:
allowForward in interface NodeBehavior
Parameters:
myNode - non-null Node to which this behavior belongs.
target - non-null Node that is not equal to myNode.

receivedPacket

public void receivedPacket(Node myNode,
                           NodePacket packet)
Event to the node behavior for when a packet is received by the Node.

Specified by:
receivedPacket in interface NodeBehavior
Parameters:
myNode - non-null Node to which this behavior belongs.
packet - non-null NodePacket destined for this behavior's Node.

sentPacket

public void sentPacket(Node myNode,
                       Node destination,
                       NodePacket packet)
Event called when a Node sends a packet to a child.

Specified by:
sentPacket in interface NodeBehavior
Parameters:
myNode - non-null Node to which this behavior belongs.
destination - non-null Node where the packet is going.
packet - non-null NodePacket destined for this behavior's Node.

hasConfidenceInformation

public boolean hasConfidenceInformation()
Returns true if this behavior has confidence information on any Node

Specified by:
hasConfidenceInformation in interface NodeBehavior

hasDebtLevelInformation

public boolean hasDebtLevelInformation()
Returns true if this behavior has debt levels for any Node

Specified by:
hasDebtLevelInformation in interface NodeBehavior

getConfidence

public java.lang.Double getConfidence(Node n)
Returns this behavior's confidence of the given Node, or null if there is no opinion.

Specified by:
getConfidence in interface NodeBehavior
Parameters:
n - non-null Node to get information about
Returns:
nullable Double

getDebtLevel

public java.lang.Double getDebtLevel(Node n)
Returns this behavior's debt level measurement of the given Node, or null if there is no opinion.

Specified by:
getDebtLevel in interface NodeBehavior
Parameters:
n - non-null Node to get information about
Returns:
nullable Double