001package gudusoft.gsqlparser.nodes; 002 003import gudusoft.gsqlparser.ESqlClause; 004import gudusoft.gsqlparser.TCustomSqlStatement; 005import gudusoft.gsqlparser.nodes.TExpression; 006import gudusoft.gsqlparser.nodes.TParseTreeNode; 007import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 008 009 010/** 011 * Oracle hierarchical_query_clause lets you select rows in a hierarchical order. 012*/ 013public class THierarchical extends TParseTreeNode { 014 015 016 private TPTNodeList<TConnectByClause> connectByList; 017 018 public TPTNodeList<TConnectByClause> getConnectByList() { 019 return connectByList; 020 } 021 022 private boolean noCycle; 023 024 public void setNoCycle(boolean noCycle) { 025 this.noCycle = noCycle; 026 } 027 028 /** 029 * 030 * @return no cycle 031 * 032 * @deprecated As of v1.6.6.6, use {@link gudusoft.gsqlparser.nodes.TConnectByClause#isNoCycle() } instead 033 */ 034 public boolean isNoCycle() { 035 036 return noCycle; 037 } 038 039 private TExpression connectByClause = null; 040 041 /** 042 * Specify a condition that identifies the row(s) to be used as the root(s) of a hierarchical query. 043 * @return start with clause 044 * 045 */ 046 public TExpression getStartWithClause() { 047 return startWithClause; 048 } 049 050 /** 051 * Specify a condition that identifies the relationship between parent rows and child rows of the hierarchy. 052 * @return connect by clause 053 * 054 * @deprecated As of v1.6.6.6, use {@link #getConnectByList()} instead 055 */ 056 public TExpression getConnectByClause() { 057 if (getConnectByList() == null) return null; 058 return getConnectByList().getElement(0).getCondition(); 059 } 060 061 private TExpression startWithClause = null; 062 063 public void init(Object arg1) 064 { 065 connectByList = (TPTNodeList)arg1; 066 } 067 public void init(Object arg1, Object arg2) 068 { 069 init(arg1); 070 startWithClause = (TExpression)arg2; 071// connectByClause = (TExpression)arg1; 072// startWithClause = (TExpression)arg2; 073 } 074 075 public void doParse(TCustomSqlStatement psql, ESqlClause plocation){ 076 if (connectByList != null){ 077 connectByList.doParse(psql,plocation); 078 } 079 080 if (startWithClause != null){ 081 startWithClause.doParse(psql,plocation); 082 } 083// if (this.connectByClause != null){ 084// this.connectByClause.doParse(psql, ESqlClause.hierarchical); 085// } 086// 087// if (this.startWithClause != null){ 088// this.startWithClause.doParse(psql,ESqlClause.hierarchical); 089// } 090 } 091 092 public void accept(TParseTreeVisitor v){ 093 v.preVisit(this); 094 v.postVisit(this); 095 } 096 097 public void acceptChildren(TParseTreeVisitor v){ 098 v.preVisit(this); 099 if (connectByList != null){ 100 for(int i=0;i<connectByList.size();i++){ 101 connectByList.getElement(i).acceptChildren(v); 102 } 103 } 104 105 if (startWithClause != null){ 106 startWithClause.acceptChildren(v); 107 } 108 v.postVisit(this); 109 } 110 111 public void setConnectByList(TPTNodeList<TConnectByClause> connectByList) { 112 this.connectByList = connectByList; 113 } 114 115 public void setConnectByClause(TExpression connectByClause) { 116 this.connectByClause = connectByClause; 117 } 118 119 public void setStartWithClause(TExpression startWithClause) { 120 this.startWithClause = startWithClause; 121 } 122}