org.onetwo.common.db.parser.JFishSqlParserManager Maven / Gradle / Ivy
The newest version!
package org.onetwo.common.db.parser;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class JFishSqlParserManager {
private final static JFishSqlParserManager instance = new JFishSqlParserManager();
public static JFishSqlParserManager getInstance() {
return instance;
}
private Map sqlCaches = new ConcurrentHashMap();
private boolean debug;
private JFishSqlParserManager(){
debug = false;
}
public SqlStatment getSqlStatment(String sql){
// int hc = sql.hashCode();
SqlStatment statments = this.sqlCaches.get(sql);
if(statments!=null){
// this.printSqlStaments(statments);
return statments;
}
JFishSqlParser sqlParser = new JFishSqlParser(sql);
sqlParser.setDebug(debug);
statments = sqlParser.parse();
if(debug){
this.printSqlStaments(statments);
}
this.sqlCaches.put(sql, statments);
return statments;
}
protected void printSqlStaments(SqlStatment statments){
if(!debug)
return ;
for(SqlObject sqlObj : statments.getSqlObjects()){
System.out.println(sqlObj);
}
}
public boolean isDebug() {
return debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
public String toString(){
return sqlCaches.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy