org.echarts.servlet.sip.appRouter.DFCRouterImpl
Class PrecedenceRules

java.lang.Object
  extended by org.echarts.servlet.sip.appRouter.DFCRouterImpl.PrecedenceRules

public class PrecedenceRules
extends java.lang.Object

This class encapsulates the complete set of precedence rule pairs that dictate the overall partial ordering among applications within a given routing region (either originating or terminating). This includes the machinery necessary for detecting and removing cycles in the precedence orderings.

Author:
khp

Constructor Summary
PrecedenceRules()
          Constructor to initialize the precdence rule set.
 
Method Summary
 void addOrderingList(org.w3c.dom.NodeList orderingNodeList)
          Given a DOM NodeList representing a list of ordering fragments, convert them to precedence pair objects and add them to the precedence rules set.
 void addRule(PrecedencePair pp)
          Add a precedence pair to the rule set.
 int compare(boolean reverse, Application a1, Application a2)
          Use the precedence rule set to determine the order of two applications.
 PrecedencePair getCycle()
          Find a cycle in the precedence rules.
 java.util.Enumeration getRules()
          Return an enumeration of the rules in the rule set.
 boolean hasRule(PrecedencePair pr)
          Check if the precedence rule set already contains the precedence pair.
 void removeRule(PrecedencePair pp)
          Remove the precedence pair from the rule set.
 java.lang.String toString()
          Render the complete set of precedence rules (without cycles) as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrecedenceRules

public PrecedenceRules()
Constructor to initialize the precdence rule set.

Method Detail

addOrderingList

public void addOrderingList(org.w3c.dom.NodeList orderingNodeList)
Given a DOM NodeList representing a list of ordering fragments, convert them to precedence pair objects and add them to the precedence rules set. An ordering fragment that only names a single application will be discarded. When all the orderings have been added to the current set of precedence rules, check for and remove cycles. The following is an example of a simple ordering cycle: app1 > app2, app2 > app1. When such cycles are detected, a minimal set of precedence pairs are discarded to remove the cycle.


toString

public java.lang.String toString()
Render the complete set of precedence rules (without cycles) as a String.

Overrides:
toString in class java.lang.Object
Returns:
String representation of precedence rules

addRule

public void addRule(PrecedencePair pp)
Add a precedence pair to the rule set. This method is not used in the current implementation. Before it is used, it will be necessary to enhance it to check for and remove cycles introduced with the addition of the the new precedence pair.

Parameters:
pp - The precedence pair to be added

hasRule

public boolean hasRule(PrecedencePair pr)
Check if the precedence rule set already contains the precedence pair. This method uses the equals() method of the PrecedencePair object to determine if the precedence pair object passed in is contained in the current rule set.

Parameters:
pr - The precedence pair object to be looked for in the current rule set.
See Also:
PrecedencePair

getCycle

public PrecedencePair getCycle()
Find a cycle in the precedence rules. As a side effect, this method builds a rule set that has no cycles.

Returns:
PrecedencePair object whose inclusion in the current rule set leads to a cycle

removeRule

public void removeRule(PrecedencePair pp)
Remove the precedence pair from the rule set.

Parameters:
pp - Precedence pair to be removed

getRules

public java.util.Enumeration getRules()
Return an enumeration of the rules in the rule set.

Returns:
Enumeration the elements of the rule set which are precedence pair objects

compare

public int compare(boolean reverse,
                   Application a1,
                   Application a2)
Use the precedence rule set to determine the order of two applications. For proper functioning, the hasCycle() method must have been called prior to invoking this method. Otherwise, the closure vector has not been properly built. Normally hasCycle() is automatically invoked as part of addOrderingList

Parameters:
reverse - a boolean that determines the order of comparison
a1 - The first application to be compared
a2 - The second application to be compared
See Also:
addOrderingList(NodeList)