001package gudusoft.gsqlparser.nodes; 002 003import gudusoft.gsqlparser.ESqlClause; 004import gudusoft.gsqlparser.ETableElementType; 005import gudusoft.gsqlparser.TCustomSqlStatement; 006import gudusoft.gsqlparser.nodes.oracle.TSupplementalLogging; 007 008 009public class TTableElement extends TParseTreeNode { 010 public static final int type_column_def = 1; 011 public static final int type_table_constraint = 2; 012 public static final int type_table_like = 3; 013 public static final int type_supplemental_logging = 4; 014 015 private int type = type_column_def; 016 017 private TObjectName parentTable = null; 018 019 private ETableElementType tableElementType = ETableElementType.column_def; 020 021 public TObjectName getParentTable() { 022 return parentTable; 023 } 024 025 private TColumnDefinition columnDefinition = null; 026 private TConstraint constraint = null; 027 private TSupplementalLogging supplementalLogging = null; 028 029 public TConstraint getConstraint() { 030 return constraint; 031 } 032 033 public void init(Object arg1, Object arg2){ 034 tableElementType = (ETableElementType)arg1; 035 switch (tableElementType){ 036 case column_def: 037 columnDefinition = (TColumnDefinition)arg2; 038 type = type_column_def; 039 break; 040 case table_constraint: 041 constraint = (TConstraint)arg2; 042 type = type_table_constraint; 043 break; 044 case table_like: 045 parentTable = (TObjectName)((TDummy)arg2).node1; 046 type = type_table_like; 047 break; 048 case supplemental_logging: 049 supplementalLogging = (TSupplementalLogging)(arg2); 050 type = type_supplemental_logging; 051 break; 052 } 053 } 054 public void init(Object arg1) 055 { 056 if (arg1 instanceof TColumnDefinition){ 057 columnDefinition = (TColumnDefinition)arg1; 058 type = type_column_def; 059 }else if (arg1 instanceof TConstraint){ 060 constraint = (TConstraint)arg1; 061 type = type_table_constraint; 062 }else if (arg1 instanceof TDummy){ 063 parentTable = (TObjectName)((TDummy)arg1).node1; 064 type = type_table_like; 065 }else if (arg1 instanceof TSupplementalLogging){ 066 supplementalLogging = (TSupplementalLogging)(arg1); 067 type = type_supplemental_logging; 068 } 069 } 070 071 public TColumnDefinition getColumnDefinition() { 072 return columnDefinition; 073 } 074 075 public int getType() { 076 077 return type; 078 } 079 080 public void doParse(TCustomSqlStatement psql, ESqlClause plocation){ 081 if (this.columnDefinition != null) 082 this.columnDefinition.doParse(psql,plocation); 083 if (this.constraint != null){ 084 this.constraint.doParse(psql,plocation); 085 } 086 } 087 088 public void accept(TParseTreeVisitor v) 089 { 090 v.preVisit(this); 091 v.postVisit(this); 092 } 093 094 public void acceptChildren(TParseTreeVisitor v) 095 { 096 v.preVisit(this); 097 v.postVisit(this); 098 } 099 100 public void setType(int type) { 101 this.type = type; 102 } 103 104 public void setParentTable(TObjectName parentTable) { 105 this.parentTable = parentTable; 106 } 107 108 public void setColumnDefinition(TColumnDefinition columnDefinition) { 109 this.columnDefinition = columnDefinition; 110 } 111 112 public void setConstraint(TConstraint constraint) { 113 this.constraint = constraint; 114 } 115 116 public void setSupplementalLogging(TSupplementalLogging supplementalLogging) { 117 this.supplementalLogging = supplementalLogging; 118 } 119}