DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Protected Member Functions | Package Functions | Properties | Private Member Functions | List of all members
Deveel.Data.Sql.Parser.DataTypeNode Class Reference

Describes the information of a data type as found in a SQL string. More...

Inheritance diagram for Deveel.Data.Sql.Parser.DataTypeNode:
Deveel.Data.Sql.Parser.SqlNode 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...
 
- 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...
 

Package Functions

 DataTypeNode ()
 Constructs an empty DataTypeNode. More...
 

Properties

bool IsPrimitive [get, private set]
 Gets a boolean value indicating if the data type found is a primitive. More...
 
string TypeName [get, private set]
 Gets the name of the data type, if IsPrimitive is true. More...
 
int Size [get, private set]
 Gets the size specification of the data-type. More...
 
bool HasSize [get, private set]
 Gets a value indicating if the data-type specification has a size value. More...
 
int Scale [get, private set]
 Gets the scaling factor of a numeric data-type. More...
 
bool HasScale [get, private set]
 Gets a value indicating if the data-type specification has a scaling factor value indicated. More...
 
int Precision [get, private set]
 Get the precision of a data-type that is NUMERIC. More...
 
bool HasPrecision [get, private set]
 In case this data-type is a NUMERIC type, this gets a value indicating if a precision specification was defined. More...
 
string Locale [get, private set]
 In case the data-type is a STRING type, this gets the locale string used to collate the values handled by the type. More...
 
bool HasLocale [get, private set]
 In case the data-type is a STRING type, this indicates if the data-type specification includes a locale definition. More...
 
string Encoding [get, private set]
 
bool HasEncoding [get, private set]
 
Dictionary< string, string > Metadata [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 GetBooleanType (ISqlNode node)
 
void GetUserType (ISqlNode node)
 
void GetMeta (ISqlNode node)
 
void GetSimpleType (ISqlNode node)
 
void GetSizedType (ISqlNode node)
 
void GetLocale (ISqlNode node)
 
void GetEncoding (ISqlNode node)
 
void GetDataSize (ISqlNode node)
 
void GetNumberType (ISqlNode node)
 
void GetNumberPrecision (ISqlNode node)
 

Additional Inherited Members

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

Detailed Description

Describes the information of a data type as found in a SQL string.

Definition at line 28 of file DataTypeNode.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Parser.DataTypeNode.DataTypeNode ( )
inlinepackage

Constructs an empty DataTypeNode.

Definition at line 32 of file DataTypeNode.cs.

32  {
33  IsPrimitive = true;
34  Metadata = new Dictionary<string, string>();
35  }
bool IsPrimitive
Gets a boolean value indicating if the data type found is a primitive.
Definition: DataTypeNode.cs:42
Dictionary< string, string > Metadata

Member Function Documentation

void Deveel.Data.Sql.Parser.DataTypeNode.GetBooleanType ( ISqlNode  node)
inlineprivate

Definition at line 141 of file DataTypeNode.cs.

141  {
142  IsPrimitive = true;
143  TypeName = "BOOLEAN";
144  }
string TypeName
Gets the name of the data type, if IsPrimitive is true.
Definition: DataTypeNode.cs:47
bool IsPrimitive
Gets a boolean value indicating if the data type found is a primitive.
Definition: DataTypeNode.cs:42
void Deveel.Data.Sql.Parser.DataTypeNode.GetDataSize ( ISqlNode  node)
inlineprivate

Definition at line 204 of file DataTypeNode.cs.

204  {
205  foreach (var childNode in node.ChildNodes) {
206  if (childNode is IntegerLiteralNode) {
207  Size = (int) ((IntegerLiteralNode) childNode).Value;
208  HasSize = true;
209  }
210  }
211  }
int Size
Gets the size specification of the data-type.
Definition: DataTypeNode.cs:56
bool HasSize
Gets a value indicating if the data-type specification has a size value.
Definition: DataTypeNode.cs:63
void Deveel.Data.Sql.Parser.DataTypeNode.GetEncoding ( ISqlNode  node)
inlineprivate

Definition at line 195 of file DataTypeNode.cs.

195  {
196  foreach (var childNode in node.ChildNodes) {
197  if (childNode is StringLiteralNode) {
198  Encoding = ((StringLiteralNode) childNode).Value;
199  HasEncoding = true;
200  }
201  }
202  }
void Deveel.Data.Sql.Parser.DataTypeNode.GetLocale ( ISqlNode  node)
inlineprivate

Definition at line 186 of file DataTypeNode.cs.

186  {
187  foreach (var childNode in node.ChildNodes) {
188  if (childNode is StringLiteralNode) {
189  Locale = ((StringLiteralNode) childNode).Value;
190  HasLocale = true;
191  }
192  }
193  }
string Locale
In case the data-type is a STRING type, this gets the locale string used to collate the values handle...
bool HasLocale
In case the data-type is a STRING type, this indicates if the data-type specification includes a loca...
void Deveel.Data.Sql.Parser.DataTypeNode.GetMeta ( ISqlNode  node)
inlineprivate

Definition at line 155 of file DataTypeNode.cs.

155  {
156  if (node == null)
157  return;
158 
159  var metas = node.FindNodes<DataTypeMetaNode>();
160  foreach (var meta in metas) {
161  Metadata[meta.Name] = meta.Value;
162  }
163  }
Dictionary< string, string > Metadata
void Deveel.Data.Sql.Parser.DataTypeNode.GetNumberPrecision ( ISqlNode  node)
inlineprivate

Definition at line 224 of file DataTypeNode.cs.

224  {
225  foreach (var childNode in node.ChildNodes) {
226  if (!HasScale) {
227  Scale = (int) ((IntegerLiteralNode) childNode).Value;
228  HasScale = true;
229  } else {
230  Precision = (int) ((IntegerLiteralNode) childNode).Value;
231  HasPrecision = true;
232  }
233  }
234  }
bool HasScale
Gets a value indicating if the data-type specification has a scaling factor value indicated...
Definition: DataTypeNode.cs:81
int Precision
Get the precision of a data-type that is NUMERIC.
Definition: DataTypeNode.cs:88
bool HasPrecision
In case this data-type is a NUMERIC type, this gets a value indicating if a precision specification w...
Definition: DataTypeNode.cs:94
int Scale
Gets the scaling factor of a numeric data-type.
Definition: DataTypeNode.cs:74
void Deveel.Data.Sql.Parser.DataTypeNode.GetNumberType ( ISqlNode  node)
inlineprivate

Definition at line 213 of file DataTypeNode.cs.

213  {
214  foreach (var childNode in node.ChildNodes) {
215  if (childNode is SqlKeyNode) {
216  TypeName = ((SqlKeyNode) childNode).Text;
217  } else if (childNode.NodeName == "number_precision") {
218  GetNumberPrecision(childNode);
219  }
220  }
221 
222  }
string TypeName
Gets the name of the data type, if IsPrimitive is true.
Definition: DataTypeNode.cs:47
void GetNumberPrecision(ISqlNode node)
void Deveel.Data.Sql.Parser.DataTypeNode.GetSimpleType ( ISqlNode  node)
inlineprivate

Definition at line 165 of file DataTypeNode.cs.

165  {
166  var type = node.ChildNodes.First();
167  TypeName = type.NodeName;
168  }
string TypeName
Gets the name of the data type, if IsPrimitive is true.
Definition: DataTypeNode.cs:47
void Deveel.Data.Sql.Parser.DataTypeNode.GetSizedType ( ISqlNode  node)
inlineprivate

Definition at line 170 of file DataTypeNode.cs.

170  {
171  foreach (var childNode in node.ChildNodes) {
172  if (childNode.NodeName == "long_varchar") {
173  TypeName = "LONG VARCHAR";
174  } else if (childNode is SqlKeyNode) {
175  TypeName = ((SqlKeyNode) childNode).Text;
176  } else if (childNode.NodeName == "datatype_size") {
177  GetDataSize(childNode);
178  } else if (childNode.NodeName == "locale_opt") {
179  GetLocale(childNode);
180  } else if (childNode.NodeName == "encoding_opt") {
181  GetEncoding(childNode);
182  }
183  }
184  }
string TypeName
Gets the name of the data type, if IsPrimitive is true.
Definition: DataTypeNode.cs:47
void Deveel.Data.Sql.Parser.DataTypeNode.GetUserType ( ISqlNode  node)
inlineprivate

Definition at line 146 of file DataTypeNode.cs.

146  {
147  IsPrimitive = false;
148  TypeName = node.FindNode<ObjectNameNode>().Name;
149  var optMetaList = node.FindByName("user_type_meta_opt");
150  if (optMetaList != null) {
151  GetMeta(optMetaList.ChildNodes.FirstOrDefault());
152  }
153  }
string TypeName
Gets the name of the data type, if IsPrimitive is true.
Definition: DataTypeNode.cs:47
bool IsPrimitive
Gets a boolean value indicating if the data type found is a primitive.
Definition: DataTypeNode.cs:42
override ISqlNode Deveel.Data.Sql.Parser.DataTypeNode.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 117 of file DataTypeNode.cs.

117  {
118  if (node.NodeName == "identity_type") {
119  TypeName = "IDENTITY";
120  } else if (node.NodeName == "boolean_type") {
121  GetBooleanType(node);
122  } else if (node.NodeName == "decimal_type") {
123  GetNumberType(node);
124  } else if (node.NodeName == "character_type" ||
125  node.NodeName == "binary_type") {
126  GetSizedType(node);
127  } else if (node.NodeName == "date_type" ||
128  node.NodeName == "integer_type" ||
129  node.NodeName == "float_type") {
130  GetSimpleType(node);
131  } else if (node.NodeName == "interval_type") {
132  } else if (node.NodeName == "user_type") {
133  GetUserType(node);
134  } else if (node.NodeName == "row_type") {
135 
136  }
137 
138  return base.OnChildNode(node);
139  }
string TypeName
Gets the name of the data type, if IsPrimitive is true.
Definition: DataTypeNode.cs:47
void GetBooleanType(ISqlNode node)

Property Documentation

string Deveel.Data.Sql.Parser.DataTypeNode.Encoding
getprivate set

Definition at line 111 of file DataTypeNode.cs.

bool Deveel.Data.Sql.Parser.DataTypeNode.HasEncoding
getprivate set

Definition at line 113 of file DataTypeNode.cs.

bool Deveel.Data.Sql.Parser.DataTypeNode.HasLocale
getprivate set

In case the data-type is a STRING type, this indicates if the data-type specification includes a locale definition.

See also
Locale

Definition at line 109 of file DataTypeNode.cs.

bool Deveel.Data.Sql.Parser.DataTypeNode.HasPrecision
getprivate set

In case this data-type is a NUMERIC type, this gets a value indicating if a precision specification was defined.

Definition at line 94 of file DataTypeNode.cs.

bool Deveel.Data.Sql.Parser.DataTypeNode.HasScale
getprivate set

Gets a value indicating if the data-type specification has a scaling factor value indicated.

See also
Scale

Definition at line 81 of file DataTypeNode.cs.

bool Deveel.Data.Sql.Parser.DataTypeNode.HasSize
getprivate set

Gets a value indicating if the data-type specification has a size value.

See also
Size

Definition at line 63 of file DataTypeNode.cs.

bool Deveel.Data.Sql.Parser.DataTypeNode.IsPrimitive
getprivate set

Gets a boolean value indicating if the data type found is a primitive.

See also
SqlType.IsPrimitive, PrimitiveTypes.IsPrimitive(Deveel.Data.Types.SqlTypeCode)

Definition at line 42 of file DataTypeNode.cs.

string Deveel.Data.Sql.Parser.DataTypeNode.Locale
getprivate set

In case the data-type is a STRING type, this gets the locale string used to collate the values handled by the type.

See also
StringType.Locale, HasLocale

Definition at line 102 of file DataTypeNode.cs.

Dictionary<string, string> Deveel.Data.Sql.Parser.DataTypeNode.Metadata
getprivate set

Definition at line 115 of file DataTypeNode.cs.

int Deveel.Data.Sql.Parser.DataTypeNode.Precision
getprivate set

Get the precision of a data-type that is NUMERIC.

See also
NumericType, HasPrecision

Definition at line 88 of file DataTypeNode.cs.

int Deveel.Data.Sql.Parser.DataTypeNode.Scale
getprivate set

Gets the scaling factor of a numeric data-type.

This value is present only if the data-type is NUMERIC.

See also
HasScale, SqlNumber.Scale, NumericType.Scale

Definition at line 74 of file DataTypeNode.cs.

int Deveel.Data.Sql.Parser.DataTypeNode.Size
getprivate set

Gets the size specification of the data-type.

In case the type is a NUMERIC type, this value is not indicated: rather check Scale property.

Definition at line 56 of file DataTypeNode.cs.

string Deveel.Data.Sql.Parser.DataTypeNode.TypeName
getprivate set

Gets the name of the data type, if IsPrimitive is true.

Definition at line 47 of file DataTypeNode.cs.


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