Changeset 1065:582a22afbc5e

Show
Ignore:
Timestamp:
05/14/10 16:05:53 (3 years ago)
Author:
tgambet
Branch:
default
convert_revision:
svn:cdcfb263-7567-472c-a848-e2c2df3466e7/trunk@1066
Message:

updated to allow the status element to be at the bottom of a response file (see observationresponse2.xsd 1.10)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/org/w3c/unicorn/response/impl/DefaultResponseXBeans.java

    r907 r1065  
    1 // $Id: DefaultResponseXBeans.java,v 1.14 2009-10-23 13:50:18 tgambet Exp $ 
     1// $Id: DefaultResponseXBeans.java,v 1.15 2010-05-14 16:05:53 tgambet Exp $ 
    22// Author: Thomas Gambet 
    33// (c) COPYRIGHT MIT, ERCIM and Keio, 2009. 
     
    2121import org.w3.x2009.x10.unicorn.observationresponse.MessageType; 
    2222import org.w3.x2009.x10.unicorn.observationresponse.ObservationresponseDocument; 
     23import org.w3.x2009.x10.unicorn.observationresponse.StatusType; 
    2324import org.w3.x2009.x10.unicorn.observationresponse.ObservationresponseDocument.Observationresponse; 
    2425import org.w3c.unicorn.Framework; 
     
    133134 
    134135        public int getStatus() { 
    135                 if (or.isSetStatus() && or.getStatus().getValue().equalsIgnoreCase("passed")) { 
    136                         return PASSED; 
    137                 } else if ((or.isSetStatus() && or.getStatus().getValue().equalsIgnoreCase("failed")) || 
    138                                   (!or.isSetStatus() && getErrorCount() > 0)) { 
    139                         return FAILED; 
    140                 } else {  
    141                         return UNDEF; 
     136                if (or.getStatusList().size() == 0) { 
     137                        if (getErrorCount() > 0) { 
     138                                return FAILED; 
     139                        } else { 
     140                                return UNDEF; 
     141                        } 
     142                } else { 
     143                        // 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. 
     144                        StatusType status = or.getStatusList().get(or.getStatusList().size() - 1); 
     145                        if (status.isSetValue() && status.getValue().equalsIgnoreCase("passed")) { 
     146                                return PASSED; 
     147                        } else if (status.isSetValue() && status.getValue().equalsIgnoreCase("failed")) { 
     148                                return FAILED; 
     149                        } else { 
     150                                return UNDEF; 
     151                        } 
    142152                } 
    143153        } 
    144154         
    145155        public Integer getRating() { 
    146                 if(or.isSetStatus() && or.getStatus().isSetRating()) 
    147                         return or.getStatus().getRating(); 
     156                if (or.getStatusList().size() != 0) { 
     157                        StatusType status = or.getStatusList().get(or.getStatusList().size() - 1); 
     158                        if (status.isSetRating()) 
     159                                return status.getRating(); 
     160                } 
    148161                return null; 
    149162        }