String str = null;
try
{
//First try to parse the header
str = reader.readLine();
if (str == null) throw new ARQException("CSV Boolean Results malformed, input is empty");
str = str.trim(); //Remove extraneous white space
//Expect a header row with single _askResult variable
if (!str.equals("_askResult")) throw new ARQException("CSV Boolean Results malformed, did not get expected ?_askResult header row");
//Then try to parse the boolean result
str = reader.readLine();
if (str == null) throw new ARQException("CSV Boolean Results malformed, unexpected end of input after header row");
str = str.trim();
if (str.toLowerCase().equals("true") || str.toLowerCase().equals("yes")) {
return true;
} else if (str.toLowerCase().equals("false") || str.toLowerCase().equals("no")) {
return false;
} else {
throw new ARQException("CSV Boolean Results malformed, expected one of - true yes false no - but got " + str);
}
}
catch (IOException ex)
{
throw new ARQException(ex);
}
}