W3C home > Mailing lists > Public > www-validator-cvs@w3.org > July 2010

unicorn commit: now considers the value of the result attribute of the cond element

From: Mercurial notifier <nobody@w3.org>
Date: Tue, 06 Jul 2010 18:05:43 +0000
To: Unicorn Updates <www-validator-cvs@w3.org>
Message-Id: <E1OWCWd-0006Pv-B5@blinky.w3.org>
changeset:   1310:8a60e89e3911
user:        Thomas Gambet <tgambet@w3.org>
date:        Tue Jul 06 14:04:13 2010 -0400
files:       src/org/w3c/unicorn/tasklisttree/MimetypeCond.java src/org/w3c/unicorn/tasklisttree/ParameterCond.java src/org/w3c/unicorn/tasklisttree/XPathCond.java
description:
now considers the value of the result attribute of the cond element


diff -r 118b88ae257a -r 8a60e89e3911 src/org/w3c/unicorn/tasklisttree/MimetypeCond.java
--- a/src/org/w3c/unicorn/tasklisttree/MimetypeCond.java	Tue Jul 06 11:54:12 2010 -0400
+++ b/src/org/w3c/unicorn/tasklisttree/MimetypeCond.java	Tue Jul 06 14:04:13 2010 -0400
@@ -6,9 +6,11 @@
 
 	@Override
 	public boolean check(UnicornCall unicornCall) {
-		
-		return value.equals(unicornCall.getInputParameter().getMimeType().toString());
-		
+		boolean b = value.equals(unicornCall.getInputParameter().getMimeType().toString());
+		if (getResult())
+			return b;
+		else
+			return !b;
 	}
 
 
diff -r 118b88ae257a -r 8a60e89e3911 src/org/w3c/unicorn/tasklisttree/ParameterCond.java
--- a/src/org/w3c/unicorn/tasklisttree/ParameterCond.java	Tue Jul 06 11:54:12 2010 -0400
+++ b/src/org/w3c/unicorn/tasklisttree/ParameterCond.java	Tue Jul 06 14:04:13 2010 -0400
@@ -8,15 +8,16 @@
 	public boolean check(UnicornCall unicornCall) {
 		
 		if (!unicornCall.getMapOfStringParameter().containsKey(parameter))
-			return false;
-		
+			return !getResult();
 		boolean passed = false;
 		String[] parameterValues = unicornCall.getMapOfStringParameter().get(parameter);
 		for (int i=0; i<parameterValues.length; i++)
 			if (parameterValues[i].equals(value))
 				passed = true;
-		
-		return passed;
+		if (getResult())
+			return passed;
+		else
+			return !passed;
 	}
 
 }
diff -r 118b88ae257a -r 8a60e89e3911 src/org/w3c/unicorn/tasklisttree/XPathCond.java
--- a/src/org/w3c/unicorn/tasklisttree/XPathCond.java	Tue Jul 06 11:54:12 2010 -0400
+++ b/src/org/w3c/unicorn/tasklisttree/XPathCond.java	Tue Jul 06 14:04:13 2010 -0400
@@ -1,43 +1,19 @@
 package org.w3c.unicorn.tasklisttree;
 
-//import org.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
 import org.w3c.unicorn.UnicornCall;
 import org.w3c.unicorn.response.Response;
 
 public class XPathCond extends TLTCond {
-
-	//private static final Log logger = LogFactory.getLog(XPathCond.class);
 	
 	@Override
 	public boolean check(UnicornCall unicornCall) {
 		Response res = unicornCall.getResponses().get(observer.getID());
 		// Testing if there is a matching response in the map and if it is passed
 		if (res != null) {
-			return res.evaluateXPath(value);
-			
-			/*String xmlStr = res.getXml().toString();
-			DocumentBuilderFactory xmlFact = DocumentBuilderFactory.newInstance();
-			xmlFact.setNamespaceAware(false);
-			try {
-				DocumentBuilder builder = xmlFact.newDocumentBuilder();
-				Document doc = builder.parse(new java.io.ByteArrayInputStream(xmlStr.getBytes("UTF-8")));
-				String xpathStr = value;
-				XPathFactory xpathFact = new XPathFactoryImpl();
-				XPath xpath = xpathFact.newXPath();
-				XPathExpression xpe = xpath.compile(xpathStr);
-				return (Boolean) xpe.evaluate(doc, XPathConstants.BOOLEAN);
-			} catch (ParserConfigurationException e) {
-				logger.error(e.getMessage(), e);
-			} catch (UnsupportedEncodingException e) {
-				logger.error(e.getMessage(), e);
-			} catch (SAXException e) {
-				logger.error(e.getMessage(), e);
-			} catch (IOException e) {
-				logger.error(e.getMessage(), e);
-			} catch (XPathExpressionException e) {
-				logger.error(e.getMessage(), e);
-			}*/
+			if (getResult())
+				return res.evaluateXPath(value);
+			else
+				return !res.evaluateXPath(value);
 		}
 		
 		return false;
Received on Tuesday, 6 July 2010 18:05:45 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:43 UTC