DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Static Public Member Functions | Properties | Private Member Functions | List of all members
Deveel.Data.Sql.Tables.ColumnInfo Class Reference

Defines the metadata properties of a column within a table of a database. More...

Inheritance diagram for Deveel.Data.Sql.Tables.ColumnInfo:
Deveel.Data.Serialization.ISerializable

Public Member Functions

 ColumnInfo (string columnName, SqlType columnType)
 Constructs a new column with the given name and type. More...
 

Static Public Member Functions

static void Serialize (ColumnInfo columnInfo, BinaryWriter writer)
 
static void Serialize (ColumnInfo columnInfo, Stream stream, Encoding encoding)
 
static void Serialize (ColumnInfo columnInfo, Stream stream)
 
static ColumnInfo Deserialize (Stream stream, ITypeResolver typeResolver)
 
static ColumnInfo Deserialize (BinaryReader reader, ITypeResolver typeResolver)
 

Properties

TableInfo TableInfo [get, set]
 Gets the table where the column is attached to. More...
 
string ColumnName [get, private set]
 Gets the name of the column. More...
 
ObjectName FullColumnName [get]
 Gets the fully qualified name of the column within the database system. More...
 
SqlType ColumnType [get, private set]
 Gets the SqlType that cells within a table for this column will handle. More...
 
int Offset [get]
 Gets the zero-based offset of the column within the containing table. More...
 
bool HasSize [get]
 
int Size [get]
 
bool HasScale [get]
 
int Scale [get]
 
bool IsIndexable [get]
 Gets a boolean vale indicating if the value of a column can participate to an index. More...
 
bool IsNotNull [get, set]
 Gets or sets a boolean value indicating if the column values are constrained to be ony NOT NULL. More...
 
SqlExpression DefaultExpression [get, set]
 Gets or sets a SqlExpression used as a DEFAULT when a constraint for the column is to SET DEFAULT. More...
 
bool HasDefaultExpression [get]
 Gets a boolean value indicating if the column has a DefaultExpression. More...
 
string IndexType [get, set]
 

Private Member Functions

 ColumnInfo (ObjectData data)
 
void ISerializable. GetData (SerializeData data)
 

Detailed Description

Defines the metadata properties of a column within a table of a database.

Columns have unique names within a table and a given SqlType that is used to define the type of data cells in the table will handle.

Definition at line 36 of file ColumnInfo.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Tables.ColumnInfo.ColumnInfo ( string  columnName,
SqlType  columnType 
)
inline

Constructs a new column with the given name and type.

Parameters
columnNameThe name of the column, as case-sensitive and unique within the table.
columnTypeThe SqlType that this column will handle.
Exceptions
ArgumentNullExceptionIf either one of columnName or columnType is null.

Definition at line 47 of file ColumnInfo.cs.

47  {
48  if (String.IsNullOrEmpty(columnName))
49  throw new ArgumentNullException("columnName");
50  if (columnType == null)
51  throw new ArgumentNullException("columnType");
52 
53 
54  ColumnType = columnType;
55  ColumnName = columnName;
56  }
A long string in the system.
string ColumnName
Gets the name of the column.
Definition: ColumnInfo.cs:79
Deveel.Data.Sql.Tables.ColumnInfo.ColumnInfo ( ObjectData  data)
inlineprivate

Definition at line 58 of file ColumnInfo.cs.

58  {
59  ColumnName = data.GetString("ColumnName");
60  ColumnType = data.GetValue<SqlType>("ColumnType");
61  IsNotNull = data.GetBoolean("IsNotNull");
62  DefaultExpression = data.GetValue<SqlExpression>("Default");
63  IndexType = data.GetString("IndexType");
64  }
bool IsNotNull
Gets or sets a boolean value indicating if the column values are constrained to be ony NOT NULL...
Definition: ColumnInfo.cs:144
Defines the properties of a specific SQL Type and handles the values compatible.
Definition: SqlType.cs:33
string ColumnName
Gets the name of the column.
Definition: ColumnInfo.cs:79
SqlExpression DefaultExpression
Gets or sets a SqlExpression used as a DEFAULT when a constraint for the column is to SET DEFAULT...
Definition: ColumnInfo.cs:151
Defines the base class for instances that represent SQL expression tree nodes.

Member Function Documentation

static ColumnInfo Deveel.Data.Sql.Tables.ColumnInfo.Deserialize ( Stream  stream,
ITypeResolver  typeResolver 
)
inlinestatic

Definition at line 198 of file ColumnInfo.cs.

198  {
199  var reader = new BinaryReader(stream, Encoding.Unicode);
200  return Deserialize(reader, typeResolver);
201  }
static ColumnInfo Deserialize(Stream stream, ITypeResolver typeResolver)
Definition: ColumnInfo.cs:198
static ColumnInfo Deveel.Data.Sql.Tables.ColumnInfo.Deserialize ( BinaryReader  reader,
ITypeResolver  typeResolver 
)
inlinestatic

Definition at line 203 of file ColumnInfo.cs.

203  {
204  var version = reader.ReadInt32();
205  if (version != 3)
206  throw new FormatException("Invalid version of the Column-Info");
207 
208  var columnName = reader.ReadString();
209  var columnType = TypeSerializer.Deserialize(reader, typeResolver);
210 
211  var notNull = reader.ReadByte() == 1;
212 
213  var columnInfo = new ColumnInfo(columnName, columnType);
214  columnInfo.IsNotNull = notNull;
215 
216  var hasDefault = reader.ReadByte() == 1;
217  if (hasDefault)
218  columnInfo.DefaultExpression = SqlExpression.Deserialize(reader);
219 
220  return columnInfo;
221  }
static SqlType Deserialize(BinaryReader reader, ITypeResolver resolver)
static SqlExpression Deserialize(BinaryReader reader)
ColumnInfo(string columnName, SqlType columnType)
Constructs a new column with the given name and type.
Definition: ColumnInfo.cs:47
Defines the base class for instances that represent SQL expression tree nodes.
void ISerializable. Deveel.Data.Sql.Tables.ColumnInfo.GetData ( SerializeData  data)
inlineprivate

Implements Deveel.Data.Serialization.ISerializable.

Definition at line 164 of file ColumnInfo.cs.

164  {
165  data.SetValue("ColumnName", ColumnName);
166  data.SetValue("ColumnType", ColumnType);
167  data.SetValue("IsNotNull", IsNotNull);
168  data.SetValue("Default", DefaultExpression);
169  data.SetValue("IndexType", IndexType);
170  }
bool IsNotNull
Gets or sets a boolean value indicating if the column values are constrained to be ony NOT NULL...
Definition: ColumnInfo.cs:144
void SetValue(string key, Type type, object value)
string ColumnName
Gets the name of the column.
Definition: ColumnInfo.cs:79
SqlExpression DefaultExpression
Gets or sets a SqlExpression used as a DEFAULT when a constraint for the column is to SET DEFAULT...
Definition: ColumnInfo.cs:151
static void Deveel.Data.Sql.Tables.ColumnInfo.Serialize ( ColumnInfo  columnInfo,
BinaryWriter  writer 
)
inlinestatic

Definition at line 173 of file ColumnInfo.cs.

173  {
174  writer.Write(3); // Version
175  writer.Write(columnInfo.ColumnName);
176 
177  TypeSerializer.SerializeTo(writer, columnInfo.ColumnType);
178 
179  writer.Write(columnInfo.IsNotNull ? (byte)1 : (byte)0);
180 
181  if (columnInfo.DefaultExpression != null) {
182  writer.Write((byte)1);
183  SqlExpression.Serialize(columnInfo.DefaultExpression, writer);
184  } else {
185  writer.Write((byte)0);
186  }
187  }
static void SerializeTo(BinaryWriter writer, SqlType type)
static void Serialize(SqlExpression expression, BinaryWriter writer)
Defines the base class for instances that represent SQL expression tree nodes.
static void Deveel.Data.Sql.Tables.ColumnInfo.Serialize ( ColumnInfo  columnInfo,
Stream  stream,
Encoding  encoding 
)
inlinestatic

Definition at line 189 of file ColumnInfo.cs.

189  {
190  var writer = new BinaryWriter(stream, encoding);
191  Serialize(columnInfo, writer);
192  }
static void Serialize(ColumnInfo columnInfo, BinaryWriter writer)
Definition: ColumnInfo.cs:173
static void Deveel.Data.Sql.Tables.ColumnInfo.Serialize ( ColumnInfo  columnInfo,
Stream  stream 
)
inlinestatic

Definition at line 194 of file ColumnInfo.cs.

194  {
195  Serialize(columnInfo, stream, Encoding.Unicode);
196  }
static void Serialize(ColumnInfo columnInfo, BinaryWriter writer)
Definition: ColumnInfo.cs:173

Property Documentation

string Deveel.Data.Sql.Tables.ColumnInfo.ColumnName
getprivate set

Gets the name of the column.

Definition at line 79 of file ColumnInfo.cs.

SqlType Deveel.Data.Sql.Tables.ColumnInfo.ColumnType
getprivate set

Gets the SqlType that cells within a table for this column will handle.

See also
SqlType

Definition at line 99 of file ColumnInfo.cs.

SqlExpression Deveel.Data.Sql.Tables.ColumnInfo.DefaultExpression
getset

Gets or sets a SqlExpression used as a DEFAULT when a constraint for the column is to SET DEFAULT.

See also
SqlExpression

Definition at line 151 of file ColumnInfo.cs.

ObjectName Deveel.Data.Sql.Tables.ColumnInfo.FullColumnName
get

Gets the fully qualified name of the column within the database system.

When TableInfo is set, the value returned is the fully qualified name of the column, otherwise this returns an instance of ObjectName that defines only ColumnName.

Definition at line 90 of file ColumnInfo.cs.

bool Deveel.Data.Sql.Tables.ColumnInfo.HasDefaultExpression
get

Gets a boolean value indicating if the column has a DefaultExpression.

See also
DefaultExpression

Definition at line 157 of file ColumnInfo.cs.

bool Deveel.Data.Sql.Tables.ColumnInfo.HasScale
get

Definition at line 120 of file ColumnInfo.cs.

bool Deveel.Data.Sql.Tables.ColumnInfo.HasSize
get

Definition at line 109 of file ColumnInfo.cs.

string Deveel.Data.Sql.Tables.ColumnInfo.IndexType
getset

Definition at line 161 of file ColumnInfo.cs.

bool Deveel.Data.Sql.Tables.ColumnInfo.IsIndexable
get

Gets a boolean vale indicating if the value of a column can participate to an index.

See also
SqlType.IsIndexable

Definition at line 136 of file ColumnInfo.cs.

bool Deveel.Data.Sql.Tables.ColumnInfo.IsNotNull
getset

Gets or sets a boolean value indicating if the column values are constrained to be ony NOT NULL.

Definition at line 144 of file ColumnInfo.cs.

int Deveel.Data.Sql.Tables.ColumnInfo.Offset
get

Gets the zero-based offset of the column within the containing table.

See also
Tables.TableInfo.IndexOfColumn(string)

Definition at line 105 of file ColumnInfo.cs.

int Deveel.Data.Sql.Tables.ColumnInfo.Scale
get

Definition at line 124 of file ColumnInfo.cs.

int Deveel.Data.Sql.Tables.ColumnInfo.Size
get

Definition at line 113 of file ColumnInfo.cs.

TableInfo Deveel.Data.Sql.Tables.ColumnInfo.TableInfo
getset

Gets the table where the column is attached to.

This value is set when this object is added to a table.

See also
Tables.TableInfo.AddColumn(ColumnInfo)

Definition at line 74 of file ColumnInfo.cs.


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