W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2009

2006/unicorn/src/org/w3c/unicorn/tasklisttree TLTIf.java,1.2,1.3

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Mon, 21 Sep 2009 13:16:56 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MpilE-0002c9-Ql@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklisttree
In directory hutz:/tmp/cvs-serv10002/src/org/w3c/unicorn/tasklisttree

Modified Files:
	TLTIf.java 
Log Message:
refactored the checkCond(TLTIF) function. TLTIf implements a check(UnicornCall) method

Index: TLTIf.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklisttree/TLTIf.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- TLTIf.java	28 Aug 2009 12:40:12 -0000	1.2
+++ TLTIf.java	21 Sep 2009 13:16:54 -0000	1.3
@@ -4,6 +4,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.w3c.unicorn.UnicornCall;
+import org.w3c.unicorn.exceptions.UnicornException;
 
 /**
  * Class made to manage the XML type : ifType in the tasklist. Included in a
@@ -15,7 +17,7 @@
  */
 public class TLTIf {
 
-	private ArrayList<TLTCond> cond;
+	private ArrayList<TLTCond> conds;
 
 	private TLTNode ifOk;
 
@@ -29,7 +31,7 @@
 	 */
 	public TLTIf() {
 		TLTIf.logger.trace("Constructor");
-		this.cond = new ArrayList<TLTCond>();
+		this.conds = new ArrayList<TLTCond>();
 		this.ifOk = new TLTNode();
 		this.ifNotOk = new TLTNode();
 	}
@@ -46,7 +48,7 @@
 	public TLTIf(ArrayList<TLTCond> cond, TLTNode ifOk) {
 		TLTIf.logger.trace("Constructor");
 		TLTIf.logger.trace("Cond : ");
-		this.cond = cond;
+		this.conds = cond;
 		this.ifOk = ifOk;
 		this.ifNotOk = new TLTNode();
 	}
@@ -65,12 +67,31 @@
 	public TLTIf(ArrayList<TLTCond> cond, TLTNode ifOk, TLTNode ifNotOK) {
 		TLTIf.logger.trace("Constructor");
 		TLTIf.logger.trace("Cond : ");
-		this.cond = cond;
+		this.conds = cond;
 		this.ifOk = ifOk;
 		this.ifNotOk = ifNotOK;
 	}
 
 	/**
+	 * Check the conditions of the if branch it makes a OR between all
+	 * conditions
+	 * 
+	 * @param unicornCall
+	 *            the UnicornCall object to check
+	 * @return whether or not the conditions are true
+	 * @throws UnicornException
+	 */
+	public boolean check(UnicornCall unicornCall) throws UnicornException {
+		boolean conditionOK = false;
+		for (TLTCond cond : conds) {
+			if (cond.check(unicornCall)) {
+				conditionOK = true;
+			}
+		}
+		return conditionOK;
+	}
+	
+	/**
 	 * Sets the child node corresponding to the "ok" case
 	 * 
 	 * @param ifOk
@@ -97,7 +118,7 @@
 	 */
 	public void addCond(TLTCond cond) {
 		TLTIf.logger.trace("addCond : " + cond.getId());
-		this.cond.add(cond);
+		this.conds.add(cond);
 	}
 
 	/**
@@ -124,13 +145,13 @@
 	 */
 	public ArrayList<TLTCond> getCondArray() {
 		TLTIf.logger.trace("getCond");
-		return cond;
+		return conds;
 	}
 
 	@Override
 	public String toString() {
 		String res = new String("TLTIf ");
-		for (TLTCond conds : this.cond) {
+		for (TLTCond conds : this.conds) {
 			res += conds.toString();
 		}
 		return res;
Received on Monday, 21 September 2009 13:17:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:14 GMT