// handle byte pretty formatting
void sqlLiteralForObject(StringBuilder buffer, Object object) {
		if (object == null) {
			buffer.append("NULL");
		} else if (object instanceof String) {
			buffer.append('\'');
			// lets escape quotes
			String literal = (String) object;
			if (literal.length() > TRIM_VALUES_THRESHOLD) {
				literal = literal.substring(0, TRIM_VALUES_THRESHOLD) + "...";
			}
			int curPos = 0;
			int endPos = 0;
			while ((endPos = literal.indexOf('\'', curPos)) >= 0) {
				buffer.append(literal.substring(curPos, endPos + 1)).append('\'');
				curPos = endPos + 1;
			}
			if (curPos < literal.length())
				buffer.append(literal.substring(curPos));
			buffer.append('\'');
		}
		// handle byte pretty formatting
		else if (object instanceof Byte) {
			IDUtil.appendFormattedByte(buffer, ((Byte) object).byteValue());
		} else if (object instanceof Number) {
			// process numeric value (do something smart in the future)
			buffer.append(object);
		} else if (object instanceof java.sql.Date) {
			buffer.append('\'').append(object).append('\'');
		} else if (object instanceof java.sql.Time) {
			buffer.append('\'').append(object).append('\'');
		} else if (object instanceof java.util.Date) {
			long time = ((java.util.Date) object).getTime();
			buffer.append('\'').append(new java.sql.Timestamp(time)).append('\'');
		} else if (object instanceof java.util.Calendar) {
			long time = ((java.util.Calendar) object).getTimeInMillis();
			buffer.append(object.getClass().getName()).append('(').append(new java.sql.Timestamp(time)).append(')');
		} else if (object instanceof Character) {
			buffer.append(((Character) object).charValue());
		} else if (object instanceof Boolean) {
			buffer.append('\'').append(object).append('\'');
		} else if (object instanceof Enum<?>) {
			// buffer.append(object.getClass().getName()).append(".");
			buffer.append(((Enum<?>) object).name()).append("=");
			if (object instanceof ExtendedEnumeration) {
				Object value = ((ExtendedEnumeration) object).getDatabaseValue();
				if (value instanceof String)
					buffer.append("'");
				buffer.append(value);
				if (value instanceof String)
					buffer.append("'");
			} else {
				buffer.append(((Enum<?>) object).ordinal());
				// FIXME -- this isn't quite right
			}
		} else if (object instanceof SQLParameterBinding) {
			sqlLiteralForObject(buffer, ((SQLParameterBinding) object).getValue());
		} else if (object.getClass().isArray()) {
			buffer.append("< ");
			int len = Array.getLength(object);
			boolean trimming = false;
			if (len > TRIM_VALUES_THRESHOLD) {
				len = TRIM_VALUES_THRESHOLD;
				trimming = true;
			}
			for (int i = 0; i < len; i++) {
				if (i > 0) {
					buffer.append(",");
				}
				sqlLiteralForObject(buffer, Array.get(object, i));
			}
			if (trimming) {
				buffer.append("...");
			}
			buffer.append('>');
		} else {
			buffer.append(object.getClass().getName()).append("@").append(System.identityHashCode(object));
		}
	}
buffer.append('\'');
}
// handle byte pretty formatting
else if (object instanceof Byte) {
IDUtil.appendFormattedByte(buffer, ((Byte) object).byteValue());
int curPos = 0;
int endPos = 0;
while ((endPos = literal.indexOf('\'', curPos)) >= 0) {
buffer.append(literal.substring(curPos, endPos + 1)).append('\'');
curPos = endPos + 1;
}
if (curPos < literal.length())
buffer.append(literal.substring(curPos));
buffer.append('\'');
}
// handle byte pretty formatting
else if (object instanceof Byte) {
IDUtil.appendFormattedByte(buffer, ((Byte) object).byteValue());
} else if (object instanceof Number) {
// process numeric value (do something smart in the future)
buffer.append(object);
} else if (object instanceof java.sql.Date) {
buffer.append('\'').append(object).append('\'');
} else if (object instanceof java.sql.Time) {
buffer.append('\'').append(object).append('\'');
} else if (object instanceof java.util.Date) {
void sqlLiteralForObject(StringBuilder buffer, Object object) {
if (object == null) {
buffer.append("NULL");
} else if (object instanceof String) {
buffer.append('\'');
// lets escape quotes
String literal = (String) object;
if (literal.length() > TRIM_VALUES_THRESHOLD) {
literal = literal.substring(0, TRIM_VALUES_THRESHOLD) + "...";
}
int curPos = 0;
int endPos = 0;
while ((endPos = literal.indexOf('\'', curPos)) >= 0) {
buffer.append(literal.substring(curPos, endPos + 1)).append('\'');
curPos = endPos + 1;
}
if (curPos < literal.length())
buffer.append(literal.substring(curPos));
buffer.append('\'');
}
// handle byte pretty formatting
else if (object instanceof Byte) {
IDUtil.appendFormattedByte(buffer, ((Byte) object).byteValue());
} else if (object instanceof Number) {
// process numeric value (do something smart in the future)
buffer.append(object);
} else if (object instanceof java.sql.Date) {
buffer.append('\'').append(object).append('\'');
} else if (object instanceof java.sql.Time) {
buffer.append('\'').append(object).append('\'');
} else if (object instanceof java.util.Date) {
long time = ((java.util.Date) object).getTime();
buffer.append('\'').append(new java.sql.Timestamp(time)).append('\'');
} else if (object instanceof java.util.Calendar) {
long time = ((java.util.Calendar) object).getTimeInMillis();
buffer.append(object.getClass().getName()).append('(').append(new java.sql.Timestamp(time)).append(')');
} else if (object instanceof Character) {
buffer.append(((Character) object).charValue());
} else if (object instanceof Boolean) {
buffer.append('\'').append(object).append('\'');
} else if (object instanceof Enum<?>) {