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

2006/unicorn/src/org/w3c/unicorn/response/impl DefaultResponseXBeans.java,1.14,1.15

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 14 May 2010 16:05:55 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1OCxOd-0004gK-B9@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/response/impl
In directory hutz:/tmp/cvs-serv17982/src/org/w3c/unicorn/response/impl

Modified Files:
	DefaultResponseXBeans.java 
Log Message:
updated to allow the status element to be at the bottom of a response file (see observationresponse2.xsd 1.10)

Index: DefaultResponseXBeans.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/response/impl/DefaultResponseXBeans.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- DefaultResponseXBeans.java	23 Oct 2009 13:50:18 -0000	1.14
+++ DefaultResponseXBeans.java	14 May 2010 16:05:53 -0000	1.15
@@ -20,6 +20,7 @@
 import org.w3.x2009.x10.unicorn.observationresponse.ListType;
 import org.w3.x2009.x10.unicorn.observationresponse.MessageType;
 import org.w3.x2009.x10.unicorn.observationresponse.ObservationresponseDocument;
+import org.w3.x2009.x10.unicorn.observationresponse.StatusType;
 import org.w3.x2009.x10.unicorn.observationresponse.ObservationresponseDocument.Observationresponse;
 import org.w3c.unicorn.Framework;
 import org.w3c.unicorn.response.Group;
@@ -132,19 +133,31 @@
 	}
 
 	public int getStatus() {
-		if (or.isSetStatus() && or.getStatus().getValue().equalsIgnoreCase("passed")) {
-			return PASSED;
-		} else if ((or.isSetStatus() && or.getStatus().getValue().equalsIgnoreCase("failed")) ||
-				  (!or.isSetStatus() && getErrorCount() > 0)) {
-			return FAILED;
-		} else { 
-			return UNDEF;
+		if (or.getStatusList().size() == 0) {
+			if (getErrorCount() > 0) {
+				return FAILED;
+			} else {
+				return UNDEF;
+			}
+		} else {
+			// Status element can be added at the top or the end of a document. If there are two status element, only the last one is used.
+			StatusType status = or.getStatusList().get(or.getStatusList().size() - 1);
+			if (status.isSetValue() && status.getValue().equalsIgnoreCase("passed")) {
+				return PASSED;
+			} else if (status.isSetValue() && status.getValue().equalsIgnoreCase("failed")) {
+				return FAILED;
+			} else {
+				return UNDEF;
+			}
 		}
 	}
 	
 	public Integer getRating() {
-		if(or.isSetStatus() && or.getStatus().isSetRating())
-			return or.getStatus().getRating();
+		if (or.getStatusList().size() != 0) {
+			StatusType status = or.getStatusList().get(or.getStatusList().size() - 1);
+			if (status.isSetRating())
+				return status.getRating();
+		}
 		return null;
 	}
 	
Received on Friday, 14 May 2010 16:05:56 UTC

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