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 if (node.getFromTable() != null) { 053 table = analyzeFromTable(node.getFromTable(), true); 054 } 055 principals = node.getPrincipals(); 056 privilegeList = node.getPrivilegeList(); 057 withOption = node.isWithOption(); 058 tableToken = node.getTableToken(); 059 060 061 062 return 0; 063 } 064 065 public void accept(TParseTreeVisitor v){ 066 v.preVisit(this); 067 v.postVisit(this); 068 } 069 070 public void acceptChildren(TParseTreeVisitor v){ 071 v.preVisit(this); 072 if (principals != null) principals.accept(v); 073 if (privilegeList != null) privilegeList.accept(v); 074 075 v.postVisit(this); 076 } 077 078 public void setPrincipals(TPTNodeList<THivePrincipalName> principals) { 079 this.principals = principals; 080 } 081 082 public void setPrivilegeList(TPTNodeList<THivePrivilegeDef> privilegeList) { 083 this.privilegeList = privilegeList; 084 } 085 086 public void setWithOption(boolean withOption) { 087 this.withOption = withOption; 088 } 089 090 public void setTable(TTable table) { 091 this.table = table; 092 } 093}