package org.springframework.web.flow;

/**
 * A factory producing transition criteria.
 * @author Keith Donald
 */
public class TransitionCriteriaFactory {

	/**
	 * Shared instance.
	 */
	public static final TransitionCriteria wildcardCriteria = new WildcardTransitionCriteria();
	
	/**
	 * Always returns true.
	 * @author Keith Donald
	 */
	public static class WildcardTransitionCriteria implements TransitionCriteria {

		/**
		 * Event id value ("*") that will cause the transition to match
		 * on any event.
		 */
		public static final String WILDCARD_EVENT_ID = "*";
		
		public boolean test(RequestContext context) {
			return true;
		}
		
		public String toString() {
			return WILDCARD_EVENT_ID;
		}

	}

	/**
	 * Negates the result of a criteria evaluation.
	 * @author Keith Donald
	 */
	public static class NotTransitionCriteria implements TransitionCriteria {

		private TransitionCriteria criteria;
		
		public NotTransitionCriteria(TransitionCriteria criteria) {
			this.criteria = criteria;
		}
		
		public boolean test(RequestContext context) {
			return !criteria.test(context);
		}
		
		public String toString() {
			return "not(" + criteria + ")";
		}
	}
	
	/**
	 * Return a criteria that always returns 'true'.
	 * @return the wildcard criteria
	 */
	public static TransitionCriteria any() {
		return wildcardCriteria;
	}
	
	/**
	 * Not the specified criteria
	 * @param criteria the criteria
	 * @return the negation
	 */
	public static TransitionCriteria not(TransitionCriteria criteria) {
		return new NotTransitionCriteria(criteria);
	}
}
@@ -59,16 +59,30 @@
 oducing 
+commonly used 
 transiti
@@ -92,17 +92,29 @@
 criteria
-.
+ objects.%0A * 
 %0A * @aut
@@ -189,135 +189,34 @@
 %09 * 
-Shared instance.%0A%09 */%0A%09public static final TransitionCriteria wildcardCriteria = new WildcardTransitionCriteria();%0A%09%0A%09/**%0A%09 * A
+Transition criteria that a
 lway
@@ -231,16 +231,21 @@
 s true.%0A
+%09 * %0A
 %09 * @aut
@@ -648,17 +648,42 @@
 /**%0A%09 * 
-N
+Transition criteria that n
 egates t
@@ -695,26 +695,19 @@
 sult of 
-a criteria
+the
  evaluat
@@ -709,17 +709,53 @@
 aluation
-.
+ of%0A%09 * another criteria object.%0A%09 * 
 %0A%09 * @au
@@ -891,24 +891,185 @@
 riteria;%0A%09%09%0A
+%09%09/**%0A%09%09 * Create a new transition criteria object that will negate%0A%09%09 * the result of given criteria object.%0A%09%09 * @param criteria the criteria to negate %0A%09%09 */%0A
 %09%09public Not
@@ -1332,19 +1332,31 @@
 * Return
+s
  a 
+transition 
 criteria
@@ -1348,32 +1348,39 @@
 sition criteria 
+object 
 that always retu
@@ -1485,24 +1485,38 @@
 urn 
-w
+new W
 ildcard
+Transition
 Criteria
 ;%0A%09%7D
@@ -1511,16 +1511,18 @@
 Criteria
+()
 ;%0A%09%7D%0A%09%0A%09
@@ -1533,15 +1533,78 @@
 %09 * 
-Not the
+Returns a transtion criteria object that negates the result of the%0A%09 *
  spe
@@ -1614,24 +1614,25 @@
 ied criteria
+.
 %0A%09 * @param 
@@ -1648,24 +1648,34 @@
 the criteria
+ to negate
 %0A%09 * @return
@@ -1685,18 +1685,27 @@
 e negati
-o
 n
+g criteria
 %0A%09 */%0A%09p

JavaDoc.