4 // Part of the Mono class libraries at
5 // mcs/class/System.Data.OracleClient/System.Data.OracleClient
7 // Assembly: System.Data.OracleClient.dll
8 // Namespace: System.Data.OracleClient
10 // Authors: Tim Coleman <tim@timcoleman.com>
11 // Atsushi Enomoto <atsushi@ximian.com>
13 // Copyright (C) Tim Coleman, 2003
15 // Licensed under the MIT/X11 License.
19 using System.Data.SqlTypes;
20 using System.Globalization;
22 namespace System.Data.OracleClient
24 public struct OracleString : IComparable, INullable
31 public static readonly OracleString Empty = new OracleString (String.Empty);
32 public static readonly OracleString Null = new OracleString ();
38 public OracleString (string s)
44 #endregion // Constructors
49 get { return !notNull; }
53 get { return value.Length; }
56 public char this [int index] {
57 get { return value [index]; }
64 #endregion // Properties
68 public int CompareTo (object value)
72 else if (!(value is OracleString))
73 throw new ArgumentException ("Value is not a System.Data.OracleClient.OracleString");
74 else if (((OracleString) value).IsNull)
77 return this.value.CompareTo (((OracleString) value).Value);
81 public static OracleBoolean GreaterThan (OracleString x, OracleString y)
83 throw new NotImplementedException ();
87 public static OracleBoolean GreaterThanOrEqual (OracleString x, OracleString y)
89 throw new NotImplementedException ();
92 public static OracleBoolean LessThan (OracleString x, OracleString y)
97 public static OracleBoolean LessThanOrEqual (OracleString x, OracleString y)
102 public static OracleString Concat (OracleString x, OracleString y)
107 public override int GetHashCode ()
109 // It returns value string's HashCode.
110 return notNull ? value.GetHashCode () : 0;
113 public override bool Equals (object o)
115 if (o is OracleString) {
116 OracleString s = (OracleString) o;
117 if (notNull && s.notNull)
118 return value == s.value;
120 throw new InvalidOperationException ("the value is Null.");
125 public static OracleBoolean Equals (OracleString x, OracleString y)
130 public static OracleBoolean NotEquals (OracleString x, OracleString y)
135 public override string ToString ()
137 return notNull ? value : "Null";
140 #endregion // Methods
144 public static OracleString operator + (OracleString x, OracleString y)
146 return (x.notNull && y.notNull) ?
147 new OracleString (x.value + y.value) :
151 public static OracleBoolean operator == (OracleString x, OracleString y)
153 return (!x.notNull || !y.notNull) ?
154 OracleBoolean.Null : new OracleBoolean (x.value == y.value);
157 public static explicit operator string (OracleString x)
163 public static OracleBoolean operator > (OracleString x, OracleString y)
165 throw new NotImplementedException ();
169 public static OracleBoolean operator >= (OracleString x, OracleString y)
171 throw new NotImplementedException ();
174 public static implicit operator OracleString (string s)
176 return new OracleString (s);
179 public static OracleBoolean operator != (OracleString x, OracleString y)
181 return (!x.notNull || !y.notNull) ?
182 OracleBoolean.Null : x.value != y.value;
185 public static OracleBoolean operator < (OracleString x, OracleString y)
187 return (!x.notNull || !y.notNull) ?
189 new OracleBoolean (String.Compare (x.value, y.value, false, CultureInfo.InvariantCulture) < 0);
192 public static OracleBoolean operator <= (OracleString x, OracleString y)
194 return (!x.notNull || !y.notNull) ?
195 OracleBoolean.Null : new OracleBoolean (String.Compare (x.value, y.value, false, CultureInfo.InvariantCulture) <= 0);
198 #endregion // Operators