directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cetin Karakus <cetin.kara...@gmail.com>
Subject clarifications of ideas regarding stage predicates
Date Mon, 13 Sep 2004 15:20:34 GMT
I would like to clarify some points regarding my ideas about predicates.
What the contract of  Stage specifies is just that Predicate's can be
added to it.
Certainly, these predicates will be used somehow by the stage in order to decide
whethet it will allow enqueue of a new event. So, my understanding is that
enqueued predicates in a stage will all have a vote whether a given event going
to be accepted to the stage. 
Now, my suggessition is that since the current contract of stage only allows 
the addition of predicates but no way of interacting with the
predicates that have
already been added to the stage, it is not possible to build complex boolean 
expressions made up of the predicates that have already been added to the stage.
What we need, IMHO, is to have a smart predicate collection accessible
through stage
interface that allows interaction with existing predicates using
boolean expressions.

To illustrate this idea,
We need to have something like this:
<pre>
public interface PredicateList
{
	/**
	 *	Enqueue a given predicate with existing predicate list in a
logical AND operation
	 */
	PredicateList andPredicate(Predicate pred);
	

	/**
	 *	Enqueue a given predicate list with existing predicate list in a
logical AND operation
	 */
	PredicateList andPredicate(PredicateList predList);

	/**
	 *	Enqueue a given predicate with existing predicate list in a
logical OR operation
	 */	
	PredicateList orPredicate(Predicate pred);

	/**
	 *	Enqueue a given predicate list with existing predicate list in a
logical OR operation
	 */	
	PredicateList orPredicate(PredicateList predList);

	 /**
		*	Evaluate the boolean expression resulting from the logical structure
		* of enqueued predicates
	  */
	 boolean eval();
}

</pre>

After we have PredicateList in place, we need to make it accessible through 
Stage. We will no longer need addPredicate method, instead we introduce
following new method:

<pre>
	PredicateList getPredicateList();
</pre>

By means of PredicateList machinery, it will be no longer  very
difficult to build such
boolean expressions:
( (predicate1 and predicate2) or (predicate3 and predicate4)) and  predicate4

<pre>
	PredicateList plist1 = new
DefaultPredicateList(predicate1).andPredicate(predicate2);
	PredicateList plist2 = new
DefaultPredicateList(predicate3).andPredicate(predicate4);
	
	stage.getPredicateList().andPredicate( plist1.orPredicate(plist2)
).andPredicate(predicate5)
</pre>

Mime
View raw message