1 19 package org.netbeans.modules.db.sql.visualeditor.querymodel; 20 21 import org.netbeans.modules.db.sql.visualeditor.parser.SQLParser; 22 import org.netbeans.modules.db.sql.visualeditor.parser.ParseException; 23 import java.util.ArrayList ; 24 25 public class SQLQueryFactory { 26 27 public static Query parse(String query) throws ParseException { 28 SQLParser parser = new SQLParser(new java.io.StringReader (query)); 29 return (Query)parser.SQLQuery(); 30 } 31 32 public static Where createWhere(Expression expr) { 33 return new WhereNode(expr); 34 } 35 36 public static Predicate createPredicate(Value val1, Value val2, String op) { 37 return new Predicate(val1, val2, op); 38 } 39 40 public static Predicate createPredicate(Value val1, Object literal, String op) { 41 Literal val2 = new Literal(literal); 42 return new Predicate(val1, val2, op); 43 } 44 45 public static Predicate createPredicate(String [] rel) { 46 return new Predicate(rel); 47 } 48 49 public static GroupBy createGroupBy(ArrayList columnList) { 50 return new GroupByNode(columnList); 51 } 52 53 public static OrderBy createOrderBy() { 54 return new OrderByNode(); 55 } 56 57 public static Column createColumn(String tableSpec, String columnName) { 58 return new ColumnNode(tableSpec, columnName); 59 } 60 61 public static Literal createLiteral(Object value) { 62 return new Literal(value); 63 } 64 65 public static Table createTable(String tableName, String corrName, String schemaName) { 66 return new TableNode(tableName, corrName, schemaName); 67 } 68 69 public static JoinTable createJoinTable(Table table) { 70 return new JoinTableNode((TableNode)table); 71 } 72 73 public static And createAnd(Expression expr1, Expression expr2) { 74 ArrayList items = new ArrayList (); 75 items.add(expr1); 76 items.add(expr2); 77 return new AndNode(items); 78 } 79 80 public static Or createOr(Expression expr1, Expression expr2) { 81 ArrayList items = new ArrayList (); 82 items.add(expr1); 83 items.add(expr2); 84 return new OrNode(items); 85 } 86 } 87 | Popular Tags |