Class QueryUtils


  • public class QueryUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escape​(java.lang.String val, char quote)
      Escapes a value for use between the given SQL quote characters, by doubling every occurrence of the quote character.
      static java.lang.String quoteIdentifier​(java.lang.String val)
      Quotes a value as a SQLite identifier, so that it is always read as a single identifier.
      static java.lang.String valuesQuery​(java.util.List<java.lang.String> columns, java.util.List<java.util.List<java.lang.Object>> valuesList)
      Build a SQLite query using the VALUES clause to return arbitrary values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QueryUtils

        public QueryUtils()
    • Method Detail

      • escape

        public static java.lang.String escape​(java.lang.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 java.lang.String quoteIdentifier​(java.lang.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 java.lang.String valuesQuery​(java.util.List<java.lang.String> columns,
                                                   java.util.List<java.util.List<java.lang.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