Class QueryUtils


  • public class QueryUtils
    extends Object
    • Constructor Detail

      • QueryUtils

        public QueryUtils()
    • Method Detail

      • escape

        public static String escape​(String val,
                                    char quote)
        Escapes a value for use between the given SQL quote characters, by doubling every occurrence of the quote character.
        Parameters:
        val - the value to escape, may be null
        quote - the quote character the value will be wrapped in, ' for a string literal or " for an identifier
        Returns:
        the escaped value, or null if val is null
      • quoteIdentifier

        public static String quoteIdentifier​(String val)
        Quotes a value as a SQLite identifier, so that it is always read as a single identifier.
        Parameters:
        val - the identifier to quote
        Returns:
        the double quoted identifier
      • valuesQuery

        public static String valuesQuery​(List<String> columns,
                                         List<List<Object>> valuesList)
        Build a SQLite query using the VALUES clause to return arbitrary values.
        Parameters:
        columns - list of column names
        valuesList - values to return as rows
        Returns:
        SQL query as string