1 19 package org.netbeans.modules.db.sql.visualeditor.querymodel; 20 21 import java.util.Collection ; 22 23 27 28 public class SetFunction extends ColumnItem implements UnaryExpression { 29 30 public static final int NONE = 0; 31 public static final int AVG = 1; 32 public static final int COUNT = 2; 33 public static final int MAX = 3; 34 public static final int MIN = 4; 35 public static final int SUM = 5; 36 37 private int _type; 38 private ColumnNode _argument; 39 private Identifier _alias; 40 41 private SetFunction() { } 42 43 public SetFunction(int type, ColumnNode argument, Identifier alias) { 44 _type = type; 45 _argument = argument; 46 _alias = alias; 47 } 48 49 Column getReferencedColumn() { 50 return _argument; 51 } 52 53 public void getReferencedColumns(Collection columns) { 54 columns.add(_argument); 55 } 56 public void getQueryItems(Collection items) { 57 items.add(_argument); 58 } 59 60 public String genText() { 61 String funcType = null; 62 switch (_type) { 63 case AVG: 64 funcType = "AVG("; 65 break; 66 case COUNT: 67 funcType = "COUNT("; 68 break; 69 case MAX: 70 funcType = "MAX("; 71 break; 72 case MIN: 73 funcType = "MIN("; 74 break; 75 case SUM: 76 funcType = "SUM("; 77 break; 78 default: 79 break; 80 } 81 funcType += _argument.genText(); 82 funcType += ")"; 83 if (_alias != null) { 84 funcType += " AS " + _alias.genText(); 85 } 86 return funcType; 87 } 88 89 public Expression findExpression(String table1, String column1, String table2, String column2) { 90 return null; 91 } 92 93 96 public void renameTableSpec(String oldTableSpec, String corrName) { 97 _argument.renameTableSpec(oldTableSpec, corrName); 98 } 99 100 public boolean isParameterized() { 101 return false; 102 } 103 104 public Expression getOperand() { 105 return _argument; 106 } 107 108 } 109 | Popular Tags |