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

Defines the properties of a specific SQL Type and handles the values compatible. More...

Inheritance diagram for Deveel.Data.Types.SqlType:
Deveel.Data.Serialization.ISerializable Deveel.Data.Routines.Function.DynamicSqlType Deveel.Data.Spatial.SpatialType Deveel.Data.Types.ArrayType Deveel.Data.Types.BinaryType Deveel.Data.Types.BooleanType Deveel.Data.Types.ColumnType Deveel.Data.Types.DateType Deveel.Data.Types.IntervalType Deveel.Data.Types.NullType Deveel.Data.Types.NumericType Deveel.Data.Types.QueryType Deveel.Data.Types.RowType Deveel.Data.Types.StringType Deveel.Data.Types.TabularType Deveel.Data.Types.UserType Deveel.Data.Xml.XmlNodeType

Public Member Functions

virtual bool IsComparable (SqlType type)
 Verifies if a given SqlType is comparable to this data-type. More...
 
virtual bool CanCastTo (SqlType destType)
 Verifies if this type can cast any value to the given SqlType. More...
 
virtual DataObject CastTo (DataObject value, SqlType destType)
 Converts the given object value to a SqlType specified. More...
 
virtual object ConvertTo (ISqlObject obj, Type destType)
 
virtual ISqlObject Add (ISqlObject a, ISqlObject b)
 
virtual ISqlObject Subtract (ISqlObject a, ISqlObject b)
 
virtual ISqlObject Multiply (ISqlObject a, ISqlObject b)
 
virtual ISqlObject Divide (ISqlObject a, ISqlObject b)
 
virtual ISqlObject Modulus (ISqlObject a, ISqlObject b)
 
virtual ISqlObject Negate (ISqlObject value)
 
virtual SqlBoolean IsEqualTo (ISqlObject a, ISqlObject b)
 
virtual SqlBoolean IsNotEqualTo (ISqlObject a, ISqlObject b)
 
virtual SqlBoolean IsGreatherThan (ISqlObject a, ISqlObject b)
 
virtual SqlBoolean IsSmallerThan (ISqlObject a, ISqlObject b)
 
virtual SqlBoolean IsGreaterOrEqualThan (ISqlObject a, ISqlObject b)
 
virtual SqlBoolean IsSmallerOrEqualThan (ISqlObject a, ISqlObject b)
 
virtual ISqlObject And (ISqlObject a, ISqlObject b)
 
virtual ISqlObject Or (ISqlObject a, ISqlObject b)
 
virtual ISqlObject XOr (ISqlObject x, ISqlObject y)
 
virtual ISqlObject UnaryPlus (ISqlObject value)
 
virtual ISqlObject Reverse (ISqlObject value)
 
virtual SqlType Wider (SqlType otherType)
 Gets the one data-type between this and the other one given that handles the wider range of values. More...
 
virtual int Compare (ISqlObject x, ISqlObject y)
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
virtual bool Equals (SqlType other)
 
override string ToString ()
 
virtual void SerializeObject (Stream stream, ISqlObject obj)
 
virtual ISqlObject DeserializeObject (Stream stream)
 
virtual bool IsCacheable (ISqlObject value)
 
virtual Type GetRuntimeType ()
 
virtual Type GetObjectType ()
 
virtual ISqlObject CreateFromLargeObject (ILargeObject objRef)
 
virtual ISqlObject CreateFrom (object value)
 

Static Public Member Functions

static SqlType Parse (string s)
 Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent. More...
 
static SqlType Parse (IContext context, string s)
 Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent. More...
 
static bool IsPrimitiveType (SqlTypeCode typeCode)
 
static SqlType Resolve (SqlTypeCode typeCode)
 
static SqlType Resolve (SqlTypeCode typeCode, DataTypeMeta[] meta)
 
static SqlType Resolve (SqlTypeCode typeCode, DataTypeMeta[] meta, ITypeResolver resolver)
 
static SqlType Resolve (SqlTypeCode typeCode, string name)
 
static SqlType Resolve (SqlTypeCode typeCode, string name, DataTypeMeta[] meta)
 
static SqlType Resolve (string name)
 
static SqlType Resolve (string name, DataTypeMeta[] meta)
 
static SqlType Resolve (string name, DataTypeMeta[] meta, ITypeResolver resolver)
 
static SqlType Resolve (SqlTypeCode typeCode, string name, DataTypeMeta[] meta, ITypeResolver resolver)
 

Protected Member Functions

 SqlType (SqlTypeCode sqlType)
 Constructs the SqlType for the given specific SQL TYPE. More...
 
 SqlType (string name, SqlTypeCode typeCode)
 Constructs the SqlType for the given specific SQL TYPE and a given name. More...
 
 SqlType (ObjectData data)
 
virtual void GetData (SerializeData data)
 

Package Functions

virtual int GetCacheUsage (ISqlObject value)
 
virtual int ColumnSizeOf (ISqlObject obj)
 

Properties

string Name [get, private set]
 Gets the name of the data-type that is used to resolve it within the context. More...
 
SqlTypeCode TypeCode [get, private set]
 Gets the kind of SQL type this data-type handles. More...
 
virtual bool IsIndexable [get]
 Indicates if the values handled by the type can be part of an index. More...
 
bool IsPrimitive [get]
 Gets a value indicating if this data-type is primitive. More...
 
bool IsNull [get]
 
virtual bool IsStorable [get]
 

Private Member Functions

void ISerializable. GetData (SerializeData data)
 

Static Private Member Functions

static SqlTypeCode ResolveTypeCode (string name)
 

Detailed Description

Defines the properties of a specific SQL Type and handles the values compatible.

Definition at line 33 of file SqlType.cs.

Constructor & Destructor Documentation

Deveel.Data.Types.SqlType.SqlType ( SqlTypeCode  sqlType)
inlineprotected

Constructs the SqlType for the given specific SQL TYPE.

This constructor will set the Name value to the equivalent of the SQL Type specified.

Parameters
sqlTypeThe code of the SQL Type this object will represent.

Definition at line 43 of file SqlType.cs.

44  : this(sqlType.ToString().ToUpperInvariant(), sqlType) {
45  }
Deveel.Data.Types.SqlType.SqlType ( string  name,
SqlTypeCode  typeCode 
)
inlineprotected

Constructs the SqlType for the given specific SQL TYPE and a given name.

Parameters
name
typeCode

Definition at line 53 of file SqlType.cs.

53  {
54  TypeCode = typeCode;
55  Name = name;
56  }
string Name
Gets the name of the data-type that is used to resolve it within the context.
Definition: SqlType.cs:75
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
Deveel.Data.Types.SqlType.SqlType ( ObjectData  data)
inlineprotected

Definition at line 58 of file SqlType.cs.

58  {
59  Name = data.GetString("Name");
60  TypeCode = (SqlTypeCode) data.GetInt32("TypeCode");
61  }
string Name
Gets the name of the data-type that is used to resolve it within the context.
Definition: SqlType.cs:75
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23

Member Function Documentation

virtual ISqlObject Deveel.Data.Types.SqlType.Add ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, and Deveel.Data.Types.StringType.

Definition at line 192 of file SqlType.cs.

192  {
193  return SqlNull.Value;
194  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
virtual ISqlObject Deveel.Data.Types.SqlType.And ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, and Deveel.Data.Types.BooleanType.

Definition at line 258 of file SqlType.cs.

258  {
259  return SqlBoolean.Null;
260  }
virtual bool Deveel.Data.Types.SqlType.CanCastTo ( SqlType  destType)
inlinevirtual

Verifies if this type can cast any value to the given SqlType.

Parameters
destTypeThe other type, destination of the cast, to verify.

By default, this method returns false, because cast process must be specified per type: when overriding the method CastTo, pay attention to also override this method accordingly.

Returns

CastTo

Reimplemented in Deveel.Data.Types.StringType, Deveel.Data.Types.NumericType, Deveel.Data.Types.DateType, Deveel.Data.Types.BooleanType, Deveel.Data.Types.UserType, and Deveel.Data.Xml.XmlNodeType.

Definition at line 153 of file SqlType.cs.

153  {
154  return false;
155  }
virtual DataObject Deveel.Data.Types.SqlType.CastTo ( DataObject  value,
SqlType  destType 
)
inlinevirtual

Converts the given object value to a SqlType specified.

Parameters
valueThe value to convert.
destTypeThe destination type of the conversion.

If the given destType destination type is equivalent to this type, it will return the value provided, otherwise it will throw an exception by default.

Casting values to specific types is specific to each data-type: override this method to support type-specific conversions.

When overriding this method, CanCastTo should be overridden accordingly to indicate the type supports casting.

Returns
Returns an instance of DataObject that is the result of the conversion from this data-type to the other type given.

Reimplemented in Deveel.Data.Types.StringType, Deveel.Data.Types.NumericType, Deveel.Data.Types.DateType, Deveel.Data.Types.BinaryType, Deveel.Data.Types.BooleanType, and Deveel.Data.Xml.XmlNodeType.

Definition at line 180 of file SqlType.cs.

180  {
181  if (Equals(destType))
182  return value;
183 
184  // TODO: Should we return a null value instead? NULL OF TYPE anyway is still a cast ...
185  throw new NotSupportedException();
186  }
override bool Equals(object obj)
Definition: SqlType.cs:373
virtual int Deveel.Data.Types.SqlType.ColumnSizeOf ( ISqlObject  obj)
inlinepackagevirtual

Reimplemented in Deveel.Data.Types.NumericType, Deveel.Data.Types.StringType, Deveel.Data.Types.DateType, Deveel.Data.Types.BooleanType, and Deveel.Data.Types.BinaryType.

Definition at line 416 of file SqlType.cs.

416  {
417  // TODO: should make this required?
418  return 0;
419  }
virtual int Deveel.Data.Types.SqlType.Compare ( ISqlObject  x,
ISqlObject  y 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.StringType, Deveel.Data.Types.NumericType, Deveel.Data.Routines.Function.DynamicSqlType, and Deveel.Data.Types.BooleanType.

Definition at line 358 of file SqlType.cs.

358  {
359  if (!x.IsComparableTo(y))
360  throw new NotSupportedException();
361 
362  if (x.IsNull && y.IsNull)
363  return 0;
364  if (x.IsNull && !y.IsNull)
365  return 1;
366  if (!x.IsNull && y.IsNull)
367  return -1;
368 
369  return ((IComparable) x).CompareTo(y);
370  }
bool IsNull
Gets a boolean value indicating if the object is NULL.
Definition: ISqlObject.cs:28
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
virtual object Deveel.Data.Types.SqlType.ConvertTo ( ISqlObject  obj,
Type  destType 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, Deveel.Data.Types.StringType, Deveel.Data.Types.NullType, and Deveel.Data.Xml.XmlNodeType.

Definition at line 188 of file SqlType.cs.

188  {
189  throw new NotSupportedException();
190  }
virtual ISqlObject Deveel.Data.Types.SqlType.CreateFrom ( object  value)
inlinevirtual

Definition at line 437 of file SqlType.cs.

437  {
438  throw new NotSupportedException(String.Format("The type {0} does not support runtime object conversion.", ToString()));
439  }
A long string in the system.
override string ToString()
Definition: SqlType.cs:395
virtual ISqlObject Deveel.Data.Types.SqlType.CreateFromLargeObject ( ILargeObject  objRef)
inlinevirtual

Definition at line 429 of file SqlType.cs.

429  {
430  throw new NotSupportedException(String.Format("SQL Type {0} cannot be created from a large object.", TypeCode));
431  }
A long string in the system.
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
virtual ISqlObject Deveel.Data.Types.SqlType.DeserializeObject ( Stream  stream)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, Deveel.Data.Types.StringType, Deveel.Data.Types.DateType, Deveel.Data.Types.BinaryType, Deveel.Data.Types.BooleanType, Deveel.Data.Types.IntervalType, Deveel.Data.Types.NullType, Deveel.Data.Types.QueryType, and Deveel.Data.Xml.XmlNodeType.

Definition at line 404 of file SqlType.cs.

404  {
405  throw new NotSupportedException(String.Format("Type {0} cannot deserialize types.", GetType()));
406  }
A long string in the system.
virtual ISqlObject Deveel.Data.Types.SqlType.Divide ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 204 of file SqlType.cs.

204  {
205  return SqlNull.Value;
206  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
override bool Deveel.Data.Types.SqlType.Equals ( object  obj)
inline

Definition at line 373 of file SqlType.cs.

373  {
374  var dataType = obj as SqlType;
375  if (dataType == null)
376  return false;
377 
378  return Equals(dataType);
379  }
SqlType(SqlTypeCode sqlType)
Constructs the SqlType for the given specific SQL TYPE.
Definition: SqlType.cs:43
override bool Equals(object obj)
Definition: SqlType.cs:373
virtual bool Deveel.Data.Types.SqlType.Equals ( SqlType  other)
inlinevirtual

Reimplemented in Deveel.Data.Types.StringType.

Definition at line 387 of file SqlType.cs.

387  {
388  if (other == null)
389  return false;
390 
391  return TypeCode == other.TypeCode;
392  }
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
virtual int Deveel.Data.Types.SqlType.GetCacheUsage ( ISqlObject  value)
inlinepackagevirtual

Definition at line 412 of file SqlType.cs.

412  {
413  return 0;
414  }
void ISerializable. Deveel.Data.Types.SqlType.GetData ( SerializeData  data)
inlineprivate

Implements Deveel.Data.Serialization.ISerializable.

Definition at line 278 of file SqlType.cs.

278  {
279  data.SetValue("Name", Name);
280  data.SetValue("TypeCode", (int) TypeCode);
281  }
void SetValue(string key, Type type, object value)
string Name
Gets the name of the data-type that is used to resolve it within the context.
Definition: SqlType.cs:75
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
virtual void Deveel.Data.Types.SqlType.GetData ( SerializeData  data)
inlineprotectedvirtual
override int Deveel.Data.Types.SqlType.GetHashCode ( )
inline

Definition at line 382 of file SqlType.cs.

382  {
383  return TypeCode.GetHashCode();
384  }
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
virtual Type Deveel.Data.Types.SqlType.GetObjectType ( )
inlinevirtual
virtual Type Deveel.Data.Types.SqlType.GetRuntimeType ( )
inlinevirtual
virtual bool Deveel.Data.Types.SqlType.IsCacheable ( ISqlObject  value)
inlinevirtual
virtual bool Deveel.Data.Types.SqlType.IsComparable ( SqlType  type)
inlinevirtual

Verifies if a given SqlType is comparable to this data-type.

Parameters
typeThe other data-type to verify the compatibility.

It is not required two SqlType to be identical to be compared: when overridden by a derived class, this methods verifies the properties of the argument type, to see if values handled by the types can be compared.

By default, this method compares the values returned by TypeCode to see if they are identical.

Returns
Returns true if the values handled by this data-type can be compared to ones handled by the given type , or false otherwise.

Reimplemented in Deveel.Data.Types.NumericType, Deveel.Data.Types.StringType, Deveel.Data.Routines.Function.DynamicSqlType, Deveel.Data.Types.DateType, Deveel.Data.Types.BooleanType, Deveel.Data.Types.IntervalType, Deveel.Data.Types.UserType, and Deveel.Data.Spatial.SpatialType.

Definition at line 137 of file SqlType.cs.

137  {
138  return TypeCode == type.TypeCode;
139  }
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
virtual SqlBoolean Deveel.Data.Types.SqlType.IsEqualTo ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 216 of file SqlType.cs.

216  {
217  if (!a.IsComparableTo(b))
218  return SqlBoolean.Null;
219 
220  return a.CompareTo(b) == 0;
221  }
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
virtual SqlBoolean Deveel.Data.Types.SqlType.IsGreaterOrEqualThan ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 244 of file SqlType.cs.

244  {
245  if (!a.IsComparableTo(b))
246  return SqlBoolean.Null;
247 
248  return a.CompareTo(b) >= 0;
249  }
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
virtual SqlBoolean Deveel.Data.Types.SqlType.IsGreatherThan ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 230 of file SqlType.cs.

230  {
231  if (!a.IsComparableTo(b))
232  return SqlBoolean.Null;
233 
234  return a.CompareTo(b) > 0;
235  }
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
virtual SqlBoolean Deveel.Data.Types.SqlType.IsNotEqualTo ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 223 of file SqlType.cs.

223  {
224  if (!a.IsComparableTo(b))
225  return SqlBoolean.Null;
226 
227  return a.CompareTo(b) != 0;
228  }
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
static bool Deveel.Data.Types.SqlType.IsPrimitiveType ( SqlTypeCode  typeCode)
inlinestatic

Definition at line 433 of file SqlType.cs.

433  {
434  return PrimitiveTypes.IsPrimitive(typeCode);
435  }
virtual SqlBoolean Deveel.Data.Types.SqlType.IsSmallerOrEqualThan ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 251 of file SqlType.cs.

251  {
252  if (!a.IsComparableTo(b))
253  return SqlBoolean.Null;
254 
255  return a.CompareTo(b) <= 0;
256  }
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
virtual SqlBoolean Deveel.Data.Types.SqlType.IsSmallerThan ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 237 of file SqlType.cs.

237  {
238  if (!a.IsComparableTo(b))
239  return SqlBoolean.Null;
240 
241  return a.CompareTo(b) < 0;
242  }
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
virtual ISqlObject Deveel.Data.Types.SqlType.Modulus ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 208 of file SqlType.cs.

208  {
209  return SqlNull.Value;
210  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
virtual ISqlObject Deveel.Data.Types.SqlType.Multiply ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 200 of file SqlType.cs.

200  {
201  return SqlNull.Value;
202  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
virtual ISqlObject Deveel.Data.Types.SqlType.Negate ( ISqlObject  value)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, and Deveel.Data.Types.BooleanType.

Definition at line 212 of file SqlType.cs.

212  {
213  return SqlNull.Value;
214  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
virtual ISqlObject Deveel.Data.Types.SqlType.Or ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, and Deveel.Data.Types.BooleanType.

Definition at line 262 of file SqlType.cs.

262  {
263  return SqlBoolean.Null;
264  }
static SqlType Deveel.Data.Types.SqlType.Parse ( string  s)
inlinestatic

Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent.

Parameters
sThe SQL formatted data-type string, defining the properties of the type.

This method only supports primitive types.

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

Definition at line 321 of file SqlType.cs.

321  {
322  return Parse(null, s);
323  }
static SqlType Parse(string s)
Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent...
Definition: SqlType.cs:321
static SqlType Deveel.Data.Types.SqlType.Parse ( IContext  context,
string  s 
)
inlinestatic

Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent.

Parameters
query
sThe SQL formatted data-type string, defining the properties of the type.

This method only supports primitive types.

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

Definition at line 338 of file SqlType.cs.

338  {
339  var sqlCompiler = SqlParsers.DataType;
340 
341  try {
342  var result = sqlCompiler.Parse(s);
343  if (result.HasErrors)
344  throw new SqlParseException(result.Errors.First().Message);
345 
346  var node = (DataTypeNode) result.RootNode;
347 
348  if (context == null && !node.IsPrimitive)
349  throw new NotSupportedException(String.Format("The type '{0}' is not primitive and no resolve context is provided.", node.TypeName));
350 
351  return DataTypeBuilder.Build(context.TypeResolver(), node);
352  } catch (SqlParseException) {
353  throw new FormatException("Unable to parse the given string to a valid data type.");
354  }
355  }
static readonly ISqlParser DataType
Definition: SqlParsers.cs:22
A long string in the system.
static SqlType Build(ITypeResolver resolver, ISqlNode sqlNode)
SqlParseResult Parse(string input)
Analyzes and parses the input and results an object that describes the parsed nodes in a tree that ca...
Describes the information of a data type as found in a SQL string.
Definition: DataTypeNode.cs:28
An error that occurs when compiling a input string into a SQL object.
static SqlType Deveel.Data.Types.SqlType.Resolve ( SqlTypeCode  typeCode)
inlinestatic

Definition at line 441 of file SqlType.cs.

441  {
442  return Resolve(typeCode, new DataTypeMeta[0]);
443  }
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( SqlTypeCode  typeCode,
DataTypeMeta[]  meta 
)
inlinestatic

Definition at line 445 of file SqlType.cs.

445  {
446  return Resolve(typeCode, meta, null);
447  }
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( SqlTypeCode  typeCode,
DataTypeMeta[]  meta,
ITypeResolver  resolver 
)
inlinestatic

Definition at line 449 of file SqlType.cs.

449  {
450  return Resolve(typeCode, typeCode.ToString().ToUpperInvariant(), meta, resolver);
451  }
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( SqlTypeCode  typeCode,
string  name 
)
inlinestatic

Definition at line 453 of file SqlType.cs.

453  {
454  return Resolve(typeCode, name, new DataTypeMeta[0]);
455  }
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( SqlTypeCode  typeCode,
string  name,
DataTypeMeta[]  meta 
)
inlinestatic

Definition at line 457 of file SqlType.cs.

457  {
458  return Resolve(typeCode, name, meta, null);
459  }
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( string  name)
inlinestatic

Definition at line 461 of file SqlType.cs.

461  {
462  return Resolve(name, new DataTypeMeta[0]);
463  }
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( string  name,
DataTypeMeta[]  meta 
)
inlinestatic

Definition at line 465 of file SqlType.cs.

465  {
466  return Resolve(name, meta, null);
467  }
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( string  name,
DataTypeMeta[]  meta,
ITypeResolver  resolver 
)
inlinestatic

Definition at line 469 of file SqlType.cs.

469  {
470  var typeCode = ResolveTypeCode(name);
471  return Resolve(typeCode, name, meta, resolver);
472  }
static SqlTypeCode ResolveTypeCode(string name)
Definition: SqlType.cs:478
static SqlType Resolve(SqlTypeCode typeCode)
Definition: SqlType.cs:441
static SqlType Deveel.Data.Types.SqlType.Resolve ( SqlTypeCode  typeCode,
string  name,
DataTypeMeta[]  meta,
ITypeResolver  resolver 
)
inlinestatic

Definition at line 474 of file SqlType.cs.

474  {
475  return TypeResolver.Resolve(typeCode, name, meta, resolver);
476  }
static SqlTypeCode Deveel.Data.Types.SqlType.ResolveTypeCode ( string  name)
inlinestaticprivate

Definition at line 478 of file SqlType.cs.

478  {
479  var typeCode = PrimitiveTypes.ResolveTypeCode(name);
480  if (typeCode == SqlTypeCode.Unknown)
481  typeCode = SqlTypeCode.Type;
482 
483  return typeCode;
484  }
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
virtual ISqlObject Deveel.Data.Types.SqlType.Reverse ( ISqlObject  value)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, and Deveel.Data.Types.BooleanType.

Definition at line 274 of file SqlType.cs.

274  {
275  return SqlNull.Value;
276  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
virtual void Deveel.Data.Types.SqlType.SerializeObject ( Stream  stream,
ISqlObject  obj 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, Deveel.Data.Types.StringType, Deveel.Data.Types.DateType, Deveel.Data.Types.BinaryType, Deveel.Data.Types.BooleanType, Deveel.Data.Types.IntervalType, Deveel.Data.Types.QueryType, Deveel.Data.Types.NullType, and Deveel.Data.Xml.XmlNodeType.

Definition at line 399 of file SqlType.cs.

399  {
400  throw new NotSupportedException(String.Format("Type {0} cannot serialize object of type {1}.", GetType(),
401  obj.GetType()));
402  }
A long string in the system.
virtual ISqlObject Deveel.Data.Types.SqlType.Subtract ( ISqlObject  a,
ISqlObject  b 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 196 of file SqlType.cs.

196  {
197  return SqlNull.Value;
198  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
override string Deveel.Data.Types.SqlType.ToString ( )
inline

Definition at line 395 of file SqlType.cs.

395  {
396  return Name;
397  }
string Name
Gets the name of the data-type that is used to resolve it within the context.
Definition: SqlType.cs:75
virtual ISqlObject Deveel.Data.Types.SqlType.UnaryPlus ( ISqlObject  value)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 270 of file SqlType.cs.

270  {
271  return SqlNull.Value;
272  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
virtual SqlType Deveel.Data.Types.SqlType.Wider ( SqlType  otherType)
inlinevirtual

Gets the one data-type between this and the other one given that handles the wider range of values.

Parameters
otherTypeThe other type to verify.

This is very important for operations and functions, when operating on objects with comparable but different data-types, to ensure the result of the operation will be capable to handle the final value.

By default, this method returns this instance, as it is not able to dynamically define the wider type.

Returns
Returns this type if it handles a wider range of values or otherType other type given otherwise.

Reimplemented in Deveel.Data.Types.NumericType.

Definition at line 305 of file SqlType.cs.

305  {
306  return this;
307  }
virtual ISqlObject Deveel.Data.Types.SqlType.XOr ( ISqlObject  x,
ISqlObject  y 
)
inlinevirtual

Reimplemented in Deveel.Data.Types.NumericType, and Deveel.Data.Types.BooleanType.

Definition at line 266 of file SqlType.cs.

266  {
267  return SqlNull.Value;
268  }
static readonly SqlNull Value
Definition: SqlNull.cs:24

Property Documentation

virtual bool Deveel.Data.Types.SqlType.IsIndexable
get

Indicates if the values handled by the type can be part of an index.

By default, this returns true, since most of primitive types are indexable (except for Long Objects).

Definition at line 100 of file SqlType.cs.

bool Deveel.Data.Types.SqlType.IsNull
get

Definition at line 111 of file SqlType.cs.

bool Deveel.Data.Types.SqlType.IsPrimitive
get

Gets a value indicating if this data-type is primitive.

Definition at line 107 of file SqlType.cs.

virtual bool Deveel.Data.Types.SqlType.IsStorable
get

Definition at line 115 of file SqlType.cs.

string Deveel.Data.Types.SqlType.Name
getprivate set

Gets the name of the data-type that is used to resolve it within the context.

This value is always unique within a database system and can be simple (eg. for primitive types like NUMERIC), or composed by multiple parts (eg. for user-defined types).

Some primitive types (for example NUMERIC) can handle multiple SQL types, so this property works as an identificator for the type handler.

Definition at line 75 of file SqlType.cs.

SqlTypeCode Deveel.Data.Types.SqlType.TypeCode
getprivate set

Gets the kind of SQL type this data-type handles.

The same instance of a SqlType can handle multiple kind of SQL types, making such instances, of the same kind, to be different in attributes.

In fact, for example a NUMERIC data-type materialized as INTEGER is not equal to NUMERIC data-type materialized as BIGINT: the two instances will be comparable, but they won't be considered coincident.

IsComparable

Definition at line 91 of file SqlType.cs.


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