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 obj)
72 else if (!(obj is OracleString))
73 throw new ArgumentException ("Value is not a System.Data.OracleClient.OracleString");
74 else if (((OracleString) obj).IsNull)
77 return value.CompareTo (((OracleString) obj).Value);
80 public static OracleBoolean GreaterThan (OracleString x, OracleString y)
82 if (x.IsNull || y.IsNull)
83 return OracleBoolean.Null;
87 public static OracleBoolean GreaterThanOrEqual (OracleString x, OracleString y)
89 if (x.IsNull || y.IsNull)
90 return OracleBoolean.Null;
94 public static OracleBoolean LessThan (OracleString x, OracleString y)
99 public static OracleBoolean LessThanOrEqual (OracleString x, OracleString y)
104 public static OracleString Concat (OracleString x, OracleString y)
109 public override int GetHashCode ()
111 // It returns value string's HashCode.
112 return notNull ? value.GetHashCode () : 0;
115 public override bool Equals (object value)
117 if (value is OracleString) {
118 OracleString s = (OracleString) value;
119 if (notNull && s.notNull)
120 return this.value == s.value;
122 throw new InvalidOperationException ("the value is Null.");
127 public static OracleBoolean Equals (OracleString x, OracleString y)
132 public static OracleBoolean NotEquals (OracleString x, OracleString y)
137 public override string ToString ()
139 return notNull ? value : "Null";
142 #endregion // Methods
146 public static OracleString operator + (OracleString x, OracleString y)
148 return (x.notNull && y.notNull) ?
149 new OracleString (x.value + y.value) :
153 public static OracleBoolean operator == (OracleString x, OracleString y)
155 return (!x.notNull || !y.notNull) ?
156 OracleBoolean.Null : new OracleBoolean (x.value == y.value);
159 public static explicit operator string (OracleString x)
165 public static OracleBoolean operator > (OracleString x, OracleString y)
167 throw new NotImplementedException ();
171 public static OracleBoolean operator >= (OracleString x, OracleString y)
173 throw new NotImplementedException ();
176 public static implicit operator OracleString (string s)
178 return new OracleString (s);
181 public static OracleBoolean operator != (OracleString x, OracleString y)
183 return (!x.notNull || !y.notNull) ?
184 OracleBoolean.Null : x.value != y.value;
187 public static OracleBoolean operator < (OracleString x, OracleString y)
189 return (!x.notNull || !y.notNull) ?
191 new OracleBoolean (String.Compare (x.value, y.value, false, CultureInfo.InvariantCulture) < 0);
194 public static OracleBoolean operator <= (OracleString x, OracleString y)
196 return (!x.notNull || !y.notNull) ?
197 OracleBoolean.Null : new OracleBoolean (String.Compare (x.value, y.value, false, CultureInfo.InvariantCulture) <= 0);
200 #endregion // Operators