handle decimals for integer and long value types

This commit is contained in:
Greg DiCristofaro 2021-01-14 09:15:22 -05:00
parent 6fda0ca726
commit 8a6d62083a

View File

@ -387,13 +387,15 @@ public final class LeappFileProcessor {
bbattributes.add(new BlackboardAttribute(attributeType, moduleName, columnValue));
} else if (attrType.matches("INTEGER")) {
try {
bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Integer.valueOf(columnValue)));
// parse as double to handle values of format like '21.0' and then convert to int
bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Double.valueOf(columnValue).intValue()));
} catch (NumberFormatException ex) {
logger.log(Level.WARNING, String.format("Unable to format %s as an integer.", columnValue), ex);
}
} else if (attrType.matches("LONG")) {
try {
bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Long.valueOf(columnValue)));
// parse as double to handle values of format like '21.0' and then convert to long
bbattributes.add(new BlackboardAttribute(attributeType, moduleName, Double.valueOf(columnValue).longValue()));
} catch (NumberFormatException ex) {
logger.log(Level.WARNING, String.format("Unable to format %s as an long.", columnValue), ex);
}