JavaScriptObject jsParams = convertParameters(parameters);
this.nativeExecuteSql(sql, jsParams, callback);
}
private final static JavaScriptObject convertParameters(Object[] parameters) {
JavaScriptObjectDecorator d = new JavaScriptObjectDecorator(JavaScriptObjectDecorator.newArray());
for (int i = 0; (parameters != null) && (i < parameters.length); i++) {
Object p = parameters[i];
if (p instanceof String) {
d.setStringProperty(Integer.toString(i), (String) p);
} else if (p instanceof Integer) {
d.setIntegerProperty(Integer.toString(i), (Integer) p);
} else if (p instanceof Date) {
d.setJavaScriptObjectProperty(Integer.toString(i),
longAsInt(Long.toString(((Date) p).getTime())));
} else if (p instanceof Float) {
d.setFloatProperty(Integer.toString(i), (Float) p);
} else if (p instanceof Double) {
d.setFloatProperty(Integer.toString(i), (Float) p);
}
}
return d.getObject();
}