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

Public Member Functions

 IntervalType (SqlTypeCode typeCode)
 
override bool IsCacheable (ISqlObject value)
 
override Type GetRuntimeType ()
 
override Type GetObjectType ()
 
override bool IsComparable (SqlType type)
 Verifies if a given SqlType is comparable to this data-type. More...
 
override void SerializeObject (Stream stream, ISqlObject obj)
 
override ISqlObject DeserializeObject (Stream stream)
 
- Public Member Functions inherited from Deveel.Data.Types.SqlType
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 ISqlObject CreateFromLargeObject (ILargeObject objRef)
 
virtual ISqlObject CreateFrom (object value)
 

Static Package Functions

static bool IsIntervalType (SqlTypeCode sqlType)
 

Properties

override bool IsIndexable [get]
 
- Properties inherited from Deveel.Data.Types.SqlType
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]
 

Static Private Member Functions

static string GetTypeString (SqlTypeCode sqlType)
 
static void AssertIsInterval (SqlTypeCode sqlType)
 

Additional Inherited Members

- Static Public Member Functions inherited from Deveel.Data.Types.SqlType
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 inherited from Deveel.Data.Types.SqlType
 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 inherited from Deveel.Data.Types.SqlType
virtual int GetCacheUsage (ISqlObject value)
 
virtual int ColumnSizeOf (ISqlObject obj)
 

Detailed Description

Definition at line 23 of file IntervalType.cs.

Constructor & Destructor Documentation

Deveel.Data.Types.IntervalType.IntervalType ( SqlTypeCode  typeCode)
inline

Definition at line 24 of file IntervalType.cs.

25  : base(GetTypeString(typeCode), typeCode) {
26  AssertIsInterval(typeCode);
27  }
static string GetTypeString(SqlTypeCode sqlType)
Definition: IntervalType.cs:33
static void AssertIsInterval(SqlTypeCode sqlType)
Definition: IntervalType.cs:42

Member Function Documentation

static void Deveel.Data.Types.IntervalType.AssertIsInterval ( SqlTypeCode  sqlType)
inlinestaticprivate

Definition at line 42 of file IntervalType.cs.

42  {
43  if (!IsIntervalType(sqlType))
44  throw new ArgumentException(String.Format("SQL Type {0} is not a valid INTERVAL.", sqlType.ToString().ToUpperInvariant()));
45  }
A long string in the system.
static bool IsIntervalType(SqlTypeCode sqlType)
override ISqlObject Deveel.Data.Types.IntervalType.DeserializeObject ( Stream  stream)
inlinevirtual

Reimplemented from Deveel.Data.Types.SqlType.

Definition at line 97 of file IntervalType.cs.

97  {
98  var reader = new BinaryReader(stream);
99 
100  var type = reader.ReadByte();
101 
102  if (type == 1) {
103  var length = reader.ReadInt32();
104  var bytes = reader.ReadBytes(length);
105 
106  // TODO: implement the constructor from bytes
107  throw new NotImplementedException();
108  }
109  if (type == 2) {
110  var months = reader.ReadInt32();
111  return new SqlYearToMonth(months);
112  }
113 
114  return base.DeserializeObject(stream);
115  }
A month span representation of time.
override Type Deveel.Data.Types.IntervalType.GetObjectType ( )
inlinevirtual

Reimplemented from Deveel.Data.Types.SqlType.

Definition at line 58 of file IntervalType.cs.

58  {
59  if (TypeCode == SqlTypeCode.YearToMonth)
60  return typeof (SqlYearToMonth);
61  if (TypeCode == SqlTypeCode.DayToSecond)
62  return typeof (SqlDayToSecond);
63 
64  return base.GetObjectType();
65  }
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
A month span representation of time.
override Type Deveel.Data.Types.IntervalType.GetRuntimeType ( )
inlinevirtual

Reimplemented from Deveel.Data.Types.SqlType.

Definition at line 51 of file IntervalType.cs.

51  {
52  if (TypeCode == SqlTypeCode.DayToSecond)
53  return typeof (TimeSpan);
54 
55  return base.GetRuntimeType();
56  }
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
static string Deveel.Data.Types.IntervalType.GetTypeString ( SqlTypeCode  sqlType)
inlinestaticprivate

Definition at line 33 of file IntervalType.cs.

33  {
34  if (sqlType == SqlTypeCode.DayToSecond)
35  return "DAY TO SECOND";
36  if (sqlType == SqlTypeCode.YearToMonth)
37  return "YEAR TO MONTH";
38 
39  return "INTERVAL";
40  }
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
override bool Deveel.Data.Types.IntervalType.IsCacheable ( ISqlObject  value)
inlinevirtual

Reimplemented from Deveel.Data.Types.SqlType.

Definition at line 47 of file IntervalType.cs.

47  {
48  return value is SqlNumber || value is SqlNull;
49  }
override bool Deveel.Data.Types.IntervalType.IsComparable ( SqlType  type)
inlinevirtual

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

Reimplemented from Deveel.Data.Types.SqlType.

Definition at line 68 of file IntervalType.cs.

68  {
69  if (!(type is IntervalType))
70  return false;
71 
72  // TODO: better check ...
73  return TypeCode.Equals(type.TypeCode);
74  }
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
Definition: SqlType.cs:91
IntervalType(SqlTypeCode typeCode)
Definition: IntervalType.cs:24
static bool Deveel.Data.Types.IntervalType.IsIntervalType ( SqlTypeCode  sqlType)
inlinestaticpackage

Definition at line 117 of file IntervalType.cs.

117  {
118  return sqlType == SqlTypeCode.YearToMonth ||
119  sqlType == SqlTypeCode.DayToSecond;
120  }
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
override void Deveel.Data.Types.IntervalType.SerializeObject ( Stream  stream,
ISqlObject  obj 
)
inlinevirtual

Reimplemented from Deveel.Data.Types.SqlType.

Definition at line 76 of file IntervalType.cs.

76  {
77  var writer = new BinaryWriter(stream);
78 
79  if (obj is SqlDayToSecond) {
80  var interval = (SqlDayToSecond) obj;
81  var bytes = interval.ToByArray();
82 
83  writer.Write((byte)1);
84  writer.Write(bytes.Length);
85  writer.Write(bytes);
86  } else if (obj is SqlYearToMonth) {
87  var interval = (SqlYearToMonth) obj;
88  var months = interval.TotalMonths;
89 
90  writer.Write((byte)2);
91  writer.Write(months);
92  }
93 
94  throw new FormatException();
95  }
A month span representation of time.

Property Documentation

override bool Deveel.Data.Types.IntervalType.IsIndexable
get

Definition at line 29 of file IntervalType.cs.


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