DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
SqlConstantExpressionNode.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 
19 using Deveel.Data.Sql.Objects;
20 
21 namespace Deveel.Data.Sql.Parser {
28  }
29 
34  public ISqlObject Value { get; private set; }
35 
37  protected override ISqlNode OnChildNode(ISqlNode node) {
38  if (node is SqlKeyNode) {
39  var keyNode = (SqlKeyNode) node;
40  if (String.Equals(keyNode.Text, "true", StringComparison.OrdinalIgnoreCase)) {
41  Value = SqlBoolean.True;
42  } else if (String.Equals(keyNode.Text, "false", StringComparison.OrdinalIgnoreCase)) {
43  Value = SqlBoolean.False;
44  } else if (String.Equals(keyNode.Text, "null", StringComparison.OrdinalIgnoreCase)) {
45  Value = SqlNull.Value;
46  } else {
47  Value = new SqlString(((SqlKeyNode) node).Text.ToCharArray());
48  }
49  } else if (node is IntegerLiteralNode) {
50  Value = new SqlNumber(((IntegerLiteralNode) node).BigValue);
51  } else if (node is NumberLiteralNode) {
52  Value = new SqlNumber(((NumberLiteralNode) node).BigValue);
53  } else if (node is StringLiteralNode) {
54  Value = new SqlString(((StringLiteralNode) node).Value.ToCharArray());
55  }
56 
57  return base.OnChildNode(node);
58  }
59  }
60 }
Defines the contract for nodes in an AST model for a SQL grammar analysis and parsing.
Definition: ISqlNode.cs:25
Represents a keyword found during the compilation of a source text.
Definition: SqlKeyNode.cs:25
Handles a numeric literal value, belonging to a wider group than integer numbers, spanning from real ...
override ISqlNode OnChildNode(ISqlNode node)
During the initialization of the node from the parser, this method is called for every child node add...
static readonly SqlNull Value
Definition: SqlNull.cs:24
Defines the contract for a valid SQL Object
Definition: ISqlObject.cs:23
A node containing a constant literal string passed within an SQL command.
An node that represents a constant value set within a context of an SQL command.
This interface acts like a marker that indicates if a ISqlNode represents a SQL expression.
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
The default implementation of ISqlNode, that is a node in the text analysis parsing of SQL commands...
Definition: SqlNode.cs:32
Encapsulates a number that is any falling in the group of integers.