public static boolean booleanFromCSV(InputStream in)
{
CSVParser parser = CSVParser.create(in) ;
final List<Var> vars = vars(parser) ;
if ( vars.size() != 1 ) {
throw new ARQException("CSV Boolean Results malformed: variables line='"+vars+"'") ;
}
if ( ! vars.get(0).getName().equals("_askResult")) {
FmtLog.warn(log, "Boolean result variable is '%s', not '_askResult'", vars.get(0).getName()) ;
}
List<String> line = parser.parse1() ;
if ( line.size() != 1 ) {
throw new ARQException("CSV Boolean Results malformed: data line='"+line+"'") ;
}
String str = line.get(0) ;
boolean b ;
if ( str.equalsIgnoreCase("true") || str.equalsIgnoreCase("yes") )
b = true ;
else if (str.equalsIgnoreCase("false") || str.equalsIgnoreCase("no"))
b = false;
else {
throw new ARQException("CSV Boolean Results malformed, expected one of - true yes false no - but got " + str);
}
List<String> line2 = parser.parse1() ;
if ( line2 != null ) {
FmtLog.warn(log, "Extra rows: first is "+line2) ;