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.FetchStatementNode Class Reference
Inheritance diagram for Deveel.Data.Sql.Parser.FetchStatementNode:
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 Direction [get, private set]
 
string CursorName [get, private set]
 
IExpressionNode Position [get, private set]
 
IExpressionNode Into [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 GetDirection (ISqlNode node)
 
void GetInto (ISqlNode node)
 

Static Private Member Functions

static bool TryParseDirection (string s, out FetchDirection direction)
 

Additional Inherited Members

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

Detailed Description

Definition at line 8 of file FetchStatementNode.cs.

Member Function Documentation

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

Implements Deveel.Data.Sql.Parser.SqlStatementNode.

Definition at line 81 of file FetchStatementNode.cs.

81  {
82  FetchDirection direction;
83  if (!TryParseDirection(Direction, out direction))
84  throw new InvalidOperationException();
85 
86  var statement = new FetchStatement(CursorName, direction);
87  if (Into != null)
88  statement.IntoReference = ExpressionBuilder.Build(Into);
89  if (Position != null)
90  statement.PositionExpression = ExpressionBuilder.Build(Position);
91 
92  builder.Statements.Add(statement);
93  }
static bool TryParseDirection(string s, out FetchDirection direction)
void Deveel.Data.Sql.Parser.FetchStatementNode.GetDirection ( ISqlNode  node)
inlineprivate

Definition at line 29 of file FetchStatementNode.cs.

29  {
30  var childNode = node.ChildNodes.FirstOrDefault();
31  if (childNode == null)
32  return;
33 
34  childNode = childNode.ChildNodes.FirstOrDefault();
35  if (childNode == null)
36  throw new SqlParseException();
37 
38  if (String.Equals(childNode.NodeName, "NEXT", StringComparison.OrdinalIgnoreCase) ||
39  String.Equals(childNode.NodeName, "PRIOR", StringComparison.OrdinalIgnoreCase) ||
40  String.Equals(childNode.NodeName, "FIRST", StringComparison.OrdinalIgnoreCase) ||
41  String.Equals(childNode.NodeName, "LAST", StringComparison.OrdinalIgnoreCase)) {
42  Direction = childNode.NodeName.ToUpper();
43  } else if (String.Equals(childNode.NodeName, "ABSOLUTE", StringComparison.OrdinalIgnoreCase) ||
44  String.Equals(childNode.NodeName, "RELATIVE", StringComparison.OrdinalIgnoreCase)) {
45  var positionNode = childNode.ChildNodes.FirstOrDefault();
46  if (positionNode == null)
47  throw new SqlParseException("The position expression if required in an ABSOLUTE or RELATIVE fetch.");
48 
49  var expression = positionNode as IExpressionNode;
50  if (expression == null)
51  throw new SqlParseException();
52 
53  Direction = childNode.NodeName.ToUpper();
54  Position = expression;
55  }
56  }
A long string in the system.
void Deveel.Data.Sql.Parser.FetchStatementNode.GetInto ( ISqlNode  node)
inlineprivate

Definition at line 58 of file FetchStatementNode.cs.

58  {
59  foreach (var childNode in node.ChildNodes) {
60  if (childNode is IExpressionNode) {
61  Into = childNode as IExpressionNode;
62  break;
63  }
64  }
65  }
override ISqlNode Deveel.Data.Sql.Parser.FetchStatementNode.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 17 of file FetchStatementNode.cs.

17  {
18  if (node.NodeName == "direction_opt") {
19  GetDirection(node);
20  } else if (node is IdentifierNode) {
21  CursorName = ((IdentifierNode) node).Text;
22  } else if (node.NodeName == "into_opt") {
23  GetInto(node);
24  }
25 
26  return base.OnChildNode(node);
27  }
static bool Deveel.Data.Sql.Parser.FetchStatementNode.TryParseDirection ( string  s,
out FetchDirection  direction 
)
inlinestaticprivate

Definition at line 67 of file FetchStatementNode.cs.

67  {
68 #if PCL
69  return Enum.TryParse(s, true, out direction);
70 #else
71  try {
72  direction = (FetchDirection) Enum.Parse(typeof (FetchDirection), s, true);
73  return true;
74  } catch (Exception) {
75  direction = new FetchDirection();
76  return false;
77  }
78 #endif
79  }

Property Documentation

string Deveel.Data.Sql.Parser.FetchStatementNode.CursorName
getprivate set

Definition at line 11 of file FetchStatementNode.cs.

string Deveel.Data.Sql.Parser.FetchStatementNode.Direction
getprivate set

Definition at line 9 of file FetchStatementNode.cs.

IExpressionNode Deveel.Data.Sql.Parser.FetchStatementNode.Into
getprivate set

Definition at line 15 of file FetchStatementNode.cs.

IExpressionNode Deveel.Data.Sql.Parser.FetchStatementNode.Position
getprivate set

Definition at line 13 of file FetchStatementNode.cs.


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