DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Protected Member Functions | Properties | Private Member Functions | Static Private Member Functions | List of all members
Deveel.Data.Sql.Parser.GrantStatementNode Class Reference
Inheritance diagram for Deveel.Data.Sql.Parser.GrantStatementNode:
Deveel.Data.Sql.Parser.SqlStatementNode Deveel.Data.Sql.Parser.SqlNode Deveel.Data.Sql.Parser.ISqlVisitableNode Deveel.Data.Sql.Parser.IStatementNode Deveel.Data.Sql.Parser.ISqlNode Deveel.Data.Sql.Parser.ISqlNode Deveel.Data.Sql.Parser.ISqlNode

Protected Member Functions

override ISqlNode OnChildNode (ISqlNode node)
 During the initialization of the node from the parser, this method is called for every child node added to ChildNodes More...
 
override void BuildStatement (StatementBuilder builder)
 
- Protected Member Functions inherited from Deveel.Data.Sql.Parser.SqlNode
virtual void OnNodeInit ()
 After the initialization of the node from the parser, this method is invoked to let the specific initialization to occur. More...
 

Properties

string ObjectName [get, private set]
 
IEnumerable< PrivilegeNodePrivileges [get, private set]
 
IEnumerable< string > Grantees [get, private set]
 
bool WithGrant [get, private set]
 
- Properties inherited from Deveel.Data.Sql.Parser.SqlNode
ISqlNode Parent [get, private set]
 Gets the parent of the current node. More...
 
string NodeName [get, private set]
 Gets the name of the node, as expressed in the SQL grammar. More...
 
IEnumerable< ISqlNodeChildNodes [get, private set]
 Gets an immutable list of nodes, children of the current node. More...
 
IEnumerable< TokenTokens [get, private set]
 Gets an immutable list of Token that represent the source of this node. More...
 
string ISqlNode. NodeName [get]
 
ISqlNode ISqlNode. Parent [get]
 
IEnumerable< ISqlNode > ISqlNode. ChildNodes [get]
 
IEnumerable< Token > ISqlNode. Tokens [get]
 
- Properties inherited from Deveel.Data.Sql.Parser.ISqlNode
string NodeName [get]
 Gets the name of the node analyzed from the parser. More...
 
ISqlNode Parent [get]
 Gets a reference to the parent ISqlNode, if any. More...
 
IEnumerable< ISqlNodeChildNodes [get]
 Gets a read-only enumeration of the children nodes, if any. More...
 
IEnumerable< TokenTokens [get]
 Gets an enumeration of the tokens composing the this node. More...
 

Private Member Functions

void GetWithGrant (ISqlNode node)
 
void GetGrantees (ISqlNode node)
 
void GetPrivileges (ISqlNode node)
 

Static Private Member Functions

static Privileges ParsePrivilege (string privName)
 

Additional Inherited Members

- Public Member Functions inherited from Deveel.Data.Sql.Parser.SqlNode
 SqlNode ()
 

Detailed Description

Definition at line 25 of file GrantStatementNode.cs.

Member Function Documentation

override void Deveel.Data.Sql.Parser.GrantStatementNode.BuildStatement ( StatementBuilder  builder)
inlineprotectedvirtual

Implements Deveel.Data.Sql.Parser.SqlStatementNode.

Definition at line 76 of file GrantStatementNode.cs.

76  {
77  var objName = Sql.ObjectName.Parse(ObjectName);
78  foreach (var grantee in Grantees) {
79  foreach (var privilegeNode in Privileges) {
80  var privilege = ParsePrivilege(privilegeNode.Privilege);
81  builder.Statements.Add(new GrantPrivilegesStatement(grantee, privilege, WithGrant, objName, privilegeNode.Columns));
82  }
83  }
84  }
static Privileges ParsePrivilege(string privName)
void Deveel.Data.Sql.Parser.GrantStatementNode.GetGrantees ( ISqlNode  node)
inlineprivate

Definition at line 53 of file GrantStatementNode.cs.

53  {
54  Grantees = node.ChildNodes.OfType<IdentifierNode>().Select(x => x.Text);
55  }
void Deveel.Data.Sql.Parser.GrantStatementNode.GetPrivileges ( ISqlNode  node)
inlineprivate

Definition at line 57 of file GrantStatementNode.cs.

57  {
58  bool isAll = false;
59 
60  foreach (var childNode in node.ChildNodes) {
61  if (childNode is SqlKeyNode) {
62  if (((SqlKeyNode) childNode).Text.Equals("ALL", StringComparison.OrdinalIgnoreCase)) {
63  isAll = true;
64  } else if (!((SqlKeyNode) childNode).Text.Equals("PRIVILEGES", StringComparison.OrdinalIgnoreCase)) {
65  throw new InvalidOperationException();
66  }
67  } else if (childNode.NodeName.Equals("priv_list")) {
68  Privileges = childNode.ChildNodes.OfType<PrivilegeNode>();
69  }
70  }
71 
72  if (isAll)
73  Privileges = new[] {PrivilegeNode.All};
74  }
void Deveel.Data.Sql.Parser.GrantStatementNode.GetWithGrant ( ISqlNode  node)
inlineprivate

Definition at line 48 of file GrantStatementNode.cs.

48  {
49  if (node.ChildNodes.Any())
50  WithGrant = true;
51  }
override ISqlNode Deveel.Data.Sql.Parser.GrantStatementNode.OnChildNode ( ISqlNode  node)
inlineprotectedvirtual

During the initialization of the node from the parser, this method is called for every child node added to ChildNodes

Parameters
nodeThe node being added to the list of children.
Returns
Returns a normalized version of the child node, or the node itself.

Reimplemented from Deveel.Data.Sql.Parser.SqlNode.

Definition at line 34 of file GrantStatementNode.cs.

34  {
35  if (node is ObjectNameNode) {
36  ObjectName = ((ObjectNameNode) node).Name;
37  } else if (node.NodeName.Equals("object_priv")) {
38  GetPrivileges(node);
39  } else if (node.NodeName.Equals("distribution_list")) {
40  GetGrantees(node);
41  } else if (node.NodeName.Equals("with_grant_opt")) {
42  GetWithGrant(node);
43  }
44 
45  return base.OnChildNode(node);
46  }
static Privileges Deveel.Data.Sql.Parser.GrantStatementNode.ParsePrivilege ( string  privName)
inlinestaticprivate

Definition at line 86 of file GrantStatementNode.cs.

86  {
87  try {
88  return (Privileges) Enum.Parse(typeof (Privileges), privName, true);
89  } catch (Exception) {
90  throw new InvalidOperationException(String.Format("Invalid privilege name '{0}' specified.", privName));
91  }
92  }
A long string in the system.

Property Documentation

IEnumerable<string> Deveel.Data.Sql.Parser.GrantStatementNode.Grantees
getprivate set

Definition at line 30 of file GrantStatementNode.cs.

string Deveel.Data.Sql.Parser.GrantStatementNode.ObjectName
getprivate set

Definition at line 26 of file GrantStatementNode.cs.

IEnumerable<PrivilegeNode> Deveel.Data.Sql.Parser.GrantStatementNode.Privileges
getprivate set

Definition at line 28 of file GrantStatementNode.cs.

bool Deveel.Data.Sql.Parser.GrantStatementNode.WithGrant
getprivate set

Definition at line 32 of file GrantStatementNode.cs.


The documentation for this class was generated from the following file: