1 19 package org.netbeans.modules.db.sql.visualeditor.querymodel; 20 21 import java.util.ArrayList ; 22 import java.util.List ; 23 import java.util.Collection ; 24 25 public class GroupByNode implements GroupBy { 26 27 29 32 private List _columnList; 34 35 36 38 public GroupByNode() { 39 } 40 41 public GroupByNode(ArrayList columnList) { 42 _columnList = columnList; 43 } 44 45 46 48 public String genText() { 49 String res = "\nGROUP BY "; 51 if (_columnList.size() > 0) { 52 res += ((ColumnNode)_columnList.get(0)).genText(); 53 for (int i=1; i<_columnList.size(); i++) { 54 res += ", " + ((ColumnNode)_columnList.get(i)).genText(); } 56 } 57 58 return res; 59 } 60 61 62 64 public void setColumnList(List columnList) { 65 _columnList = columnList; 66 } 67 68 public void getReferencedColumns(Collection columns) { 70 if (_columnList != null) 71 columns.addAll(_columnList); 72 } 73 74 public void getQueryItems(Collection items) { 75 if (_columnList != null) 76 items.addAll(_columnList); 77 } 78 79 public void addColumn(Column col) { 80 _columnList.add(col); 81 } 82 83 public void addColumn(String tableSpec, String columnName) { 84 _columnList.add(new ColumnNode(tableSpec, columnName)); 85 } 86 87 public void removeColumn(String tableSpec, String columnName) { 90 for (int i=_columnList.size()-1; i>=0; i--) { 91 ColumnNode c = (ColumnNode) _columnList.get(i); 92 if ((c.getTableSpec().equals(tableSpec)) && 93 (c.getColumnName().equals(columnName))) { 94 _columnList.remove(i); 95 } 96 } 97 } 98 99 102 void removeTable (String tableSpec) { 103 for (int i=_columnList.size()-1; i>=0; i--) { 104 ColumnNode c = (ColumnNode) _columnList.get(i); 105 if (c.getTableSpec().equals(tableSpec)) 106 _columnList.remove(i); 107 } 108 } 109 110 void renameTableSpec(String oldTableSpec, String corrName) { 111 112 for (int i=0; i<_columnList.size(); i++) 113 ((ColumnNode)_columnList.get(i)).renameTableSpec(oldTableSpec, corrName); 114 } 115 } 116 | Popular Tags |