001package gudusoft.gsqlparser.nodes; 002 003 004import gudusoft.gsqlparser.ESortType; 005 006public class TColumnWithSortOrder extends TParseTreeNode { 007 008 /** 009 * Expression for functional/expression indexes (MySQL 8.0+, PostgreSQL, etc.) 010 * When this is set, columnName is null. 011 */ 012 private TExpression expression; 013 014 public void setExpression(TExpression expression) { 015 this.expression = expression; 016 } 017 018 /** 019 * Returns the expression for a functional index. 020 * For regular column indexes, this returns null and getColumnName() returns the column. 021 * @return the index expression, or null if this is a regular column index 022 */ 023 public TExpression getExpression() { 024 return expression; 025 } 026 027 private TTable ownerTable; 028 029 public void setOwnerTable(TTable ownerTable) { 030 this.ownerTable = ownerTable; 031 } 032 033 public TTable getOwnerTable() { 034 035 return ownerTable; 036 } 037 038 public void setOwnerConstraint(TConstraint ownerConstraint) { 039 this.ownerConstraint = ownerConstraint; 040 } 041 042 /** 043 * Constraint where this column resides. 044 * @return 045 */ 046 public TConstraint getOwnerConstraint() { 047 048 return ownerConstraint; 049 } 050 051 private TConstraint ownerConstraint; 052 053 private TConstant length; 054 055 public void setLength(TConstant length) { 056 this.length = length; 057 } 058 059 /** 060 * MySQL index column 061 * @return 062 */ 063 public TConstant getLength() { 064 065 return length; 066 } 067 068 public TColumnWithSortOrder(){ 069 } 070 071 public TColumnWithSortOrder(TObjectName columnName){ 072 this.sortType = ESortType.none; 073 this.columnName = columnName; 074 } 075 public TColumnWithSortOrder(TObjectName columnName,ESortType sortType){ 076 this(columnName); 077 this.sortType = sortType; 078 } 079 public void setColumnName(TObjectName columnName) { 080 this.columnName = columnName; 081 } 082 083 public void setSortType(ESortType sortType) { 084 this.sortType = sortType; 085 } 086 087 public TObjectName getColumnName() { 088 089 return columnName; 090 } 091 092 public ESortType getSortType() { 093 return sortType; 094 } 095 096 private TObjectName columnName; 097 private ESortType sortType; 098 099 public void init(Object arg1){ 100 columnName = (TObjectName)arg1; 101 } 102 103 public void init(Object arg1,Object arg2){ 104 init(arg1); 105 this.sortType = (ESortType)arg2; 106 } 107 108 public void accept(TParseTreeVisitor v){ 109 v.preVisit(this); 110 v.postVisit(this); 111 } 112 113 public void acceptChildren(TParseTreeVisitor v){ 114 v.preVisit(this); 115 v.postVisit(this); 116 } 117 118}