* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Data.OracleClient / System.Data.OracleClient / OracleMonthSpan.cs
1 //
2 // OracleMonthSpan.cs 
3 //
4 // Part of the Mono class libraries at
5 // mcs/class/System.Data.OracleClient/System.Data.OracleClient
6 //
7 // Assembly: System.Data.OracleClient.dll
8 // Namespace: System.Data.OracleClient
9 //
10 // Author: Tim Coleman <tim@timcoleman.com>
11 //
12 // Copyright (C) Tim Coleman, 2003
13 //
14 // Licensed under the MIT/X11 License.
15 //
16
17 using System;
18 using System.Data.SqlTypes;
19
20 namespace System.Data.OracleClient {
21         public struct OracleMonthSpan : IComparable, INullable
22         {
23                 #region Fields
24
25                 public static readonly OracleMonthSpan MaxValue = new OracleMonthSpan (176556);
26                 public static readonly OracleMonthSpan MinValue = new OracleMonthSpan (-176556);
27                 public static readonly OracleMonthSpan Null = new OracleMonthSpan ();
28
29                 bool notNull; 
30                 int value;
31
32                 #endregion // Fields
33
34                 #region Constructors
35
36                 public OracleMonthSpan (int months)
37                 {
38                         value = months;
39                         notNull = true;
40                 }
41
42                 public OracleMonthSpan (OracleMonthSpan from)
43                 {
44                         this.notNull = from.notNull;
45                         this.value = from.value;
46                 }
47
48                 public OracleMonthSpan (int years, int months)
49                         : this (years * 12 + months)
50                 {
51                 }
52
53                 #endregion // Constructors
54
55                 #region Properties
56
57                 public bool IsNull {
58                         get { return !notNull; }
59                 }
60
61                 public int Value {
62                         get {
63                                 if (IsNull)
64                                         throw new Exception ("Data is null.");
65
66                                 return value;
67                         }
68                 }
69
70                 #endregion // Properties
71
72                 #region Methods
73
74                 [MonoTODO]
75                 public int CompareTo (object obj)
76                 {
77                         throw new NotImplementedException ();
78                 }
79
80                 [MonoTODO]
81                 public override bool Equals (object value)
82                 {
83                         throw new NotImplementedException ();
84                 }
85
86                 public static OracleBoolean Equals (OracleMonthSpan x, OracleMonthSpan y)
87                 {
88                         if (x.IsNull || y.IsNull)
89                                 return OracleBoolean.Null;
90                         return new OracleBoolean (x.Value == y.Value);
91                 }
92
93                 [MonoTODO]
94                 public override int GetHashCode ()
95                 {
96                         throw new NotImplementedException ();
97                 }
98
99                 public static OracleBoolean GreaterThan (OracleMonthSpan x, OracleMonthSpan y)
100                 {
101                         if (x.IsNull || y.IsNull)
102                                 return OracleBoolean.Null;
103                         return (x.value > y.value);
104                 }
105
106                 public static OracleBoolean GreaterThanOrEqual (OracleMonthSpan x, OracleMonthSpan y)
107                 {
108                         if (x.IsNull || y.IsNull)
109                                 return OracleBoolean.Null;
110                         return (x.value >= y.value);
111                 }
112
113                 public static OracleBoolean LessThan (OracleMonthSpan x, OracleMonthSpan y)
114                 {
115                         if (x.IsNull || y.IsNull)
116                                 return OracleBoolean.Null;
117                         return (x.value < y.value);
118                 }
119
120                 public static OracleBoolean LessThanOrEqual (OracleMonthSpan x, OracleMonthSpan y)
121                 {
122                         if (x.IsNull || y.IsNull)
123                                 return OracleBoolean.Null;
124                         return (x.value <= y.value);
125                 }
126
127                 public static OracleBoolean NotEquals (OracleMonthSpan x, OracleMonthSpan y)
128                 {
129                         if (x.IsNull || y.IsNull)
130                                 return OracleBoolean.Null;
131                         return (x.value != y.value);
132                 }
133                 
134                 public static OracleMonthSpan Parse (string s)
135                 {
136                         return new OracleMonthSpan (Int32.Parse (s));
137                 }
138
139                 public override string ToString ()
140                 {
141                         if (IsNull)
142                                 return "Null";
143                         return value.ToString ();
144                 }
145
146                 #endregion // Methods
147
148                 #region Operators and Type Conversions
149
150                 public static OracleBoolean operator == (OracleMonthSpan x, OracleMonthSpan y)
151                 {
152                         return Equals (x, y);
153                 }
154
155                 public static OracleBoolean operator > (OracleMonthSpan x, OracleMonthSpan y)
156                 {
157                         return GreaterThan (x, y);
158                 }
159
160                 public static OracleBoolean operator >= (OracleMonthSpan x, OracleMonthSpan y)
161                 {
162                         return GreaterThanOrEqual (x, y);
163                 }
164
165                 public static OracleBoolean operator != (OracleMonthSpan x, OracleMonthSpan y)
166                 {
167                         return NotEquals (x, y);
168                 }
169
170                 public static OracleBoolean operator < (OracleMonthSpan x, OracleMonthSpan y)
171                 {
172                         return LessThan (x, y);
173                 }
174
175                 public static OracleBoolean operator <= (OracleMonthSpan x, OracleMonthSpan y)
176                 {
177                         return LessThan (x, y);
178                 }
179
180                 public static explicit operator int (OracleMonthSpan x)
181                 {
182                         return x.value;
183                 }
184
185                 public static explicit operator OracleMonthSpan (string s)
186                 {
187                         return Parse (s);
188                 }
189
190                 #endregion // Operators and Type Conversions
191         }
192 }