public static ISqlJetBtreeRecord getRecord(SqlJetEncoding encoding, Object... values) throws SqlJetException {
final List<ISqlJetVdbeMem> fields = new ArrayList<ISqlJetVdbeMem>(values.length);
for (int i = 0; i < values.length; i++) {
final Object value = values[i];
final ISqlJetVdbeMem mem = new SqlJetVdbeMem();
if (null == value) {
mem.setNull();
} else if (value instanceof String) {
mem.setStr(SqlJetUtility.fromString((String) value, encoding), encoding);
} else if (value instanceof Boolean) {
mem.setInt64(((Boolean) value) ? 1 : 0);
} else if (value instanceof Byte) {
mem.setInt64((Byte) value);
} else if (value instanceof Short) {
mem.setInt64((Short) value);
} else if (value instanceof Integer) {
mem.setInt64((Integer) value);
} else if (value instanceof Long) {
mem.setInt64((Long) value);
} else if (value instanceof Float) {
mem.setDouble((Float) value);
} else if (value instanceof Double) {
mem.setDouble((Double) value);
} else if (value instanceof ByteBuffer) {
mem.setStr(SqlJetUtility.fromByteBuffer((ByteBuffer) value), encoding);
mem.setTypeFlag(SqlJetVdbeMemFlags.Blob);
} else if (value instanceof InputStream) {
mem.setStr(SqlJetUtility.streamToBuffer((InputStream) value), encoding);
mem.setTypeFlag(SqlJetVdbeMemFlags.Blob);
} else if ("byte[]".equalsIgnoreCase(value.getClass().getCanonicalName())) {
mem.setStr(SqlJetUtility.wrapPtr((byte[]) value), encoding);
mem.setTypeFlag(SqlJetVdbeMemFlags.Blob);
} else {
throw new SqlJetException(SqlJetErrorCode.MISUSE, "Bad value #" + i + " " + value.toString());
}
fields.add(mem);
}