if (query.indexOf('?')>-1) {
int n = query.length();
int param = offset;
int paramCount = parameters.length;
char ch;
Any data;
StringBuffer buffer = new StringBuffer(1 + n + n/2);
int i = 0;
while(i<n) {
switch((ch = query.charAt(i++))) {
case '?':
if (i<n && query.charAt(i) == '?') {
buffer.append('?');
i++;
break;
}
data = ((parameters != null) && (param < paramCount)) ? parameters[param++] : Any.NULL;
switch(data.typeOf()) {
case Any.IS_NULL:
case Any.IS_UNDEFINED:
buffer.append("null");
break;
case Any.IS_BOOLEAN:
buffer.append(data.toBoolean() ? "'true'" : "'false'");
break;
case Any.IS_INT:
buffer.append(data.toLong());
break;
case Any.IS_DOUBLE:
buffer.append(data.toDouble());
break;
case Any.IS_STRING:
case Any.IS_BUFFER:
case Any.IS_BINARY:
buffer.append('\'');
Conversions.escape(buffer, data.toString(), true);
buffer.append('\'');
break;
default:
buffer.append("null");
break;
}
break;
case '$':
if (i<n && query.charAt(i) == '$') {
buffer.append('$');
i++;
} else {
data = ((parameters != null) && (param < paramCount)) ? parameters[param++] : Any.NULL;
buffer.append(data.toString());
}
break;
default:
buffer.append(ch);