From 6f932191b6efdb389238b7f620102a7a7067b943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Tue, 30 Jan 2018 00:33:24 +0100 Subject: [PATCH] catch number parse exception in literal creation --- .../content/rdf/internal/DefaultLiteral.java | 33 +++++++++++-------- gradle.properties | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultLiteral.java b/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultLiteral.java index 3a6f1a9..ecfc726 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultLiteral.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultLiteral.java @@ -94,20 +94,25 @@ public class DefaultLiteral implements Literal, Comparable { 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; } } diff --git a/gradle.properties b/gradle.properties index c257dc8..dc55aa0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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