001package gudusoft.gsqlparser.stmt.hive; 002/* 003 * Date: 13-7-29 004 */ 005 006import gudusoft.gsqlparser.EDbVendor; 007import gudusoft.gsqlparser.ESqlStatementType; 008import gudusoft.gsqlparser.TCustomSqlStatement; 009import gudusoft.gsqlparser.TSourceToken; 010import gudusoft.gsqlparser.nodes.*; 011import gudusoft.gsqlparser.nodes.hive.THiveGrantSqlNode; 012import gudusoft.gsqlparser.nodes.hive.THivePrincipalName; 013import gudusoft.gsqlparser.nodes.hive.THivePrivilegeDef; 014 015public class THiveGrant extends TCustomSqlStatement { 016 017 private TPTNodeList<THivePrincipalName> principals; 018 private TPTNodeList <THivePrivilegeDef> privilegeList; 019 private boolean withOption; 020 private TTable table; 021 private TSourceToken tableToken; 022 023 public THiveGrant(EDbVendor dbvendor) { 024 super(dbvendor); 025 sqlstatementtype = ESqlStatementType.ssthiveGrant; 026 } 027 028 public TPTNodeList<THivePrincipalName> getPrincipals() { 029 return principals; 030 } 031 032 public TPTNodeList<THivePrivilegeDef> getPrivilegeList() { 033 return privilegeList; 034 } 035 036 public boolean isWithOption() { 037 return withOption; 038 } 039 040 public TTable getTable() { 041 return table; 042 } 043 044 public TSourceToken getTableToken() { 045 return tableToken; 046 } 047 048 public int doParseStatement(TCustomSqlStatement psql) { 049 if (rootNode == null) return -1; 050 super.doParseStatement(psql); 051 THiveGrantSqlNode node = (THiveGrantSqlNode)rootNode; 052 table = analyzeFromTable(node.getFromTable(),true); 053 principals = node.getPrincipals(); 054 privilegeList = node.getPrivilegeList(); 055 withOption = node.isWithOption(); 056 tableToken = node.getTableToken(); 057 058 059 060 return 0; 061 } 062 063 public void accept(TParseTreeVisitor v){ 064 v.preVisit(this); 065 v.postVisit(this); 066 } 067 068 public void acceptChildren(TParseTreeVisitor v){ 069 v.preVisit(this); 070 if (principals != null) principals.accept(v); 071 if (privilegeList != null) privilegeList.accept(v); 072 073 v.postVisit(this); 074 } 075 076 public void setPrincipals(TPTNodeList<THivePrincipalName> principals) { 077 this.principals = principals; 078 } 079 080 public void setPrivilegeList(TPTNodeList<THivePrivilegeDef> privilegeList) { 081 this.privilegeList = privilegeList; 082 } 083 084 public void setWithOption(boolean withOption) { 085 this.withOption = withOption; 086 } 087 088 public void setTable(TTable table) { 089 this.table = table; 090 } 091}