Ngsi2ParsingHelper { public static Object parseTextValue(String value) { if (value.equalsIgnoreCase("true")) { return true; } else if (value.equalsIgnoreCase("false")) { return false; } else if (value.equalsIgnoreCase("null")) { return null; } else if (value.startsWith("\"") && value.endsWith("\"") && value.length() > 1) { return value.substring(1, value.length()-1); } try { return Integer.parseInt(value); } catch (NumberFormatException ignored) {} try { return Long.parseLong(value); } catch (NumberFormatException ignored) {} try { return Float.parseFloat(value); } catch (NumberFormatException ignored) {} try { return Double.parseDouble(value); } catch (NumberFormatException ignored) {} throw new NotAcceptableException(); }  static Object parseTextValue(String value); static GeoQuery parseGeoQuery(String georel, String geometry, String coords); static GeoQuery.Geometry parseGeometry(String geometry); static List<Coordinate> parseCoordinates(String stringCoord);  }
@Test public void testParseTextValue() { assertEquals("hello world", Ngsi2ParsingHelper.parseTextValue("\"hello world\"")); assertEquals(true, Ngsi2ParsingHelper.parseTextValue("true")); assertEquals(false, Ngsi2ParsingHelper.parseTextValue("false")); assertEquals(null, Ngsi2ParsingHelper.parseTextValue("null")); assertEquals(1, Ngsi2ParsingHelper.parseTextValue("1")); assertEquals(1.2f, Ngsi2ParsingHelper.parseTextValue("1.2")); }