/** * Double quote the given string; double quotes are escaped. If the given string is null, this * method returns a quoted empty string ({@code ""}). * * @param value The value to double quote. * @return The double quoted string. */ public static String doubleQuote(String value) { return quote(value, '"'); }
@Override public String format(String value) { if (value == null) return "NULL"; return ParseUtils.quote(value); }
/** * Quote the given string; single quotes are escaped. If the given string is null, this method * returns a quoted empty string ({@code ''}). * * @param value The value to quote. * @return The quoted string. */ public static String quote(String value) { return quote(value, '\''); }
@Override public String format(Long value) { if (value == null) return "NULL"; return ParseUtils.quote(ParseUtils.formatTime(value)); } }
@Override public String format(LocalDate value) { if (value == null) return "NULL"; return ParseUtils.quote(value.toString()); }
@Test(groups = "unit") public void testQuote() { assertThat(ParseUtils.quote(null)).isEqualTo("''"); assertThat(ParseUtils.quote("")).isEqualTo("''"); assertThat(ParseUtils.quote(" ")).isEqualTo("' '"); assertThat(ParseUtils.quote("foo")).isEqualTo("'foo'"); assertThat(ParseUtils.quote(" 'foo' ")).isEqualTo("' ''foo'' '"); }
/** * Quote the given string; single quotes are escaped. * If the given string is null, this method returns a quoted empty string ({@code ''}). * * @param value The value to quote. * @return The quoted string. */ public static String quote(String value) { return quote(value, '\''); }
@Override public String format(String value) { if (value == null) return "NULL"; return ParseUtils.quote(value); }
/** * Quote the given string; single quotes are escaped. * If the given string is null, this method returns a quoted empty string ({@code ''}). * * @param value The value to quote. * @return The quoted string. */ public static String quote(String value) { return quote(value, '\''); }
/** * Double quote the given string; double quotes are escaped. * If the given string is null, this method returns a quoted empty string ({@code ""}). * * @param value The value to double quote. * @return The double quoted string. */ public static String doubleQuote(String value) { return quote(value, '"'); }
@Override public String format(String value) { if (value == null) return "NULL"; return ParseUtils.quote(value); }
@Override public String format(String value) { if (value == null) return "NULL"; return ParseUtils.quote(value); }
@Override public String format(Long value) { if (value == null) return "NULL"; return quote(Long.toString(value)); } }
@Override public String format(LocalDate value) { if (value == null) return "NULL"; return quote(FORMATTER.print(value)); }
@Override public String format(java.time.Instant value) { if (value == null) return "NULL"; return quote(FORMATTER.format(value)); }
@Override public String format(T value) throws InvalidTypeException { if (value == null) return "NULL"; String json; try { json = objectMapper.writeValueAsString(value); } catch (IOException e) { throw new InvalidTypeException(e.getMessage(), e); } return ParseUtils.quote(json); }
@Override public String format(LocalDate value) { if (value == null) return "NULL"; return ParseUtils.quote(value.toString()); }
@Override public String format(LocalDate value) { if (value == null) return "NULL"; return ParseUtils.quote(value.toString()); }
@Override public String format(Long value) { if (value == null) return "NULL"; return ParseUtils.quote(ParseUtils.formatTime(value)); }