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,10 +94,12 @@ public class DefaultLiteral implements Literal, Comparable<Literal> {
return value; return value;
} }
String s = value.toString(); String s = value.toString();
try {
switch (type.toString()) { switch (type.toString()) {
case "xsd:long": case "xsd:long":
return Long.parseLong(s); return Long.parseLong(s);
case "xsd:int": case "xsd:int":
return Integer.parseInt(s);
case "xsd:gYear": case "xsd:gYear":
return Integer.parseInt(s); return Integer.parseInt(s);
case "xsd:boolean": case "xsd:boolean":
@ -109,6 +111,9 @@ public class DefaultLiteral implements Literal, Comparable<Literal> {
default: default:
return s; return s;
} }
} catch (NumberFormatException e) {
return null;
}
} }
@Override @Override

View file

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