code: public static String prepareValue(Object val) {
          StringBuilder result = new StringBuilder();
          
          boolean numberOrBooleanOrNull;
          if (val != null && !(val instanceof Number) && !(val instanceof Boolean)) {
              numberOrBooleanOrNull = false;
              result.append("'");
          } else {
              numberOrBooleanOrNull = true;
          }
          if (val instanceof Boolean) {
              Boolean boolVal = (Boolean) val;
              if (boolVal.equals(Boolean.TRUE)) {
                  result.append(1);
              } else {
                  result.append(0);
              }
          } else {
              result.append(val);
          }
          if (!numberOrBooleanOrNull) {
              result.append("'");
          }
          return result.toString();
      }
docs: Generates an SQL-ready string for the given value based on its type.
  
  @param val the value to prepare
  @return a <tt>String</tt> ready to be appended to an SQL statement