DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
QueryResultColumn.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 using System.IO;
19 
20 using Deveel.Data.Sql;
21 using Deveel.Data.Sql.Tables;
22 using Deveel.Data.Types;
23 
24 namespace Deveel.Data.Protocol {
25  public class QueryResultColumn {
32  private QueryResultColumn(string name, SqlType type, bool notNull) {
33  Name = name;
34  Type = type;
35  IsNotNull = notNull;
36  IsUnique = false;
37  UniqueGroup = -1;
38  }
39 
40  internal QueryResultColumn(string name, ColumnInfo columnInfo)
41  : this(name, columnInfo.ColumnType, columnInfo.IsNotNull) {
42 
43  }
44 
52  public void SetUnique() {
53  IsUnique = true;
54  }
55 
64  public string Name { get; private set; }
65 
66  public SqlType Type { get; private set; }
67 
71  public bool IsNumericType {
72  get { return (Type is NumericType); }
73  }
74 
75 
80  public int Size {
81  get { return (Type is ISizeableType) ? ((ISizeableType)Type).Size : -1; }
82  }
83 
88  public int Scale {
89  get { return (Type is NumericType) ? ((NumericType) Type).Scale : -1; }
90  }
91 
98  public bool IsNotNull { get; private set; }
99 
106  public bool IsUnique { get; private set; }
107 
116  public int UniqueGroup { get; set; }
117 
118  public bool IsAliased {
119  get { return Name.StartsWith("@a"); }
120  }
121 
122  public Type RuntimeType {
123  get { return Type.GetRuntimeType(); }
124  }
125 
126  public Type ValueType {
127  get { return Type.GetObjectType(); }
128  }
129 
131  public override bool Equals(Object ob) {
132  var cd = (QueryResultColumn)ob;
133  return (Name.Equals(cd.Name) &&
134  Type == cd.Type &&
135  Size == cd.Size &&
136  IsNotNull == cd.IsNotNull &&
137  IsUnique == cd.IsUnique &&
138  UniqueGroup == cd.UniqueGroup);
139  }
140 
141  public override int GetHashCode() {
142  return base.GetHashCode();
143  }
144  }
145 }
Defines the metadata properties of a column within a table of a database.
Definition: ColumnInfo.cs:36
QueryResultColumn(string name, ColumnInfo columnInfo)
QueryResultColumn(string name, SqlType type, bool notNull)
The Constructors if the type does require a size.
A user-defined TYPE that holds complex objects in a database column.
Defines the properties of a specific SQL Type and handles the values compatible.
Definition: SqlType.cs:33
void SetUnique()
Sets this column to unique.