catch number parse exception in literal creation

This commit is contained in:
Jörg Prante 2018-01-30 00:33:24 +01:00
parent f065ce40bd
commit 6f932191b6
2 changed files with 20 additions and 15 deletions

View file

@ -94,20 +94,25 @@ public class DefaultLiteral implements Literal, Comparable<Literal> {
return value;
}
String s = value.toString();
switch (type.toString()) {
case "xsd:long":
return Long.parseLong(s);
case "xsd:int":
case "xsd:gYear":
return Integer.parseInt(s);
case "xsd:boolean":
return Boolean.parseBoolean(s);
case "xsd:float":
return Float.parseFloat(s);
case "xsd:double":
return Double.parseDouble(s);
default:
return s;
try {
switch (type.toString()) {
case "xsd:long":
return Long.parseLong(s);
case "xsd:int":
return Integer.parseInt(s);
case "xsd:gYear":
return Integer.parseInt(s);
case "xsd:boolean":
return Boolean.parseBoolean(s);
case "xsd:float":
return Float.parseFloat(s);
case "xsd:double":
return Double.parseDouble(s);
default:
return s;
}
} catch (NumberFormatException e) {
return null;
}
}

View file

@ -1,6 +1,6 @@
group = org.xbib
name = content
version = 1.2.1
version = 1.2.2
jackson.version = 2.8.11
xbib-net.version = 1.0.0