use of com.alibaba.druid.sql.visitor.VisitorFeature in project druid by alibaba.
the class SQLUtils method toSQLString.
public static String toSQLString(SQLObject sqlObject, DbType dbType, FormatOption option, VisitorFeature... features) {
StringBuilder out = new StringBuilder();
SQLASTOutputVisitor visitor = createOutputVisitor(out, dbType);
if (option == null) {
option = DEFAULT_FORMAT_OPTION;
}
visitor.setUppCase(option.isUppCase());
visitor.setPrettyFormat(option.isPrettyFormat());
visitor.setParameterized(option.isParameterized());
int featuresValue = option.features;
if (features != null) {
for (VisitorFeature feature : features) {
visitor.config(feature, true);
featuresValue |= feature.mask;
}
}
visitor.setFeatures(featuresValue);
sqlObject.accept(visitor);
String sql = out.toString();
return sql;
}
Aggregations