com.poiji.parser.BooleanParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of poiji2 Show documentation
Show all versions of poiji2 Show documentation
Perfect annotation based library to read and write excel files
package com.poiji.parser;
public class BooleanParser implements Parser {
@Override
public Boolean parse(String value) {
if ("true".equalsIgnoreCase(value.trim())) {
return true;
}
if ("false".equalsIgnoreCase(value.trim())) {
return false;
}
/* LibreOffice compatibility:
*
* LibreOffice booleans are stored as formula =TRUE() or =FALSE() which is parsed by POI to 1 or 0.
*/
if ("1".equals(value.trim())) {
return true;
}
if ("0".equals(value.trim())) {
return false;
}
throw new BooleanParseException(value);
}
@SuppressWarnings("serial")
public static class BooleanParseException extends RuntimeException {
public BooleanParseException(String value) {
super("Can't parse value to Boolean: " + value);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy