Welcome to mirror list, hosted at ThFree Co, Russian Federation.

OracleLob.cs « System.Data.OracleClient.jvm « System.Data.OracleClient « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a7f9a1e73f1ea02ec71c273f241b0dad15c15a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329

using System;
using System.Data.SqlTypes;
using System.IO;
using System.Text;

namespace System.Data.OracleClient {
	public sealed class OracleLob : Stream, ICloneable, INullable {
		#region Fields

		public static readonly new OracleLob Null = new OracleLob ();

		internal OracleConnection connection;
		bool isBatched = false;
		bool isOpen = true;
		bool notNull = false;
		OracleType type;

		long length = -1;
		long position = 1;

		#endregion // Fields

		#region Constructors

		internal OracleLob () {
		}


		#endregion // Constructors

		#region Properties

		public override bool CanRead {
			get { return (IsNull || isOpen); }
		}

		public override bool CanSeek {
			get { return (IsNull || isOpen); }
		}

		public override bool CanWrite {
			get { return isOpen; }
		}

		public int ChunkSize {
			[MonoTODO]
			get { 
				AssertConnectionIsOpen ();
				AssertObjectNotDisposed ();
				throw new NotImplementedException ();
			}
		}

		public OracleConnection Connection {
			get { return connection; }
		}

		public bool IsBatched {
			get { return isBatched; }
		}

		public bool IsNull {
			get { return !notNull; }
		}

		public bool IsTemporary {
			get { 
				AssertConnectionIsOpen ();
				AssertObjectNotDisposed ();
				throw new NotImplementedException ();
			}
		}

		public override long Length {
			get { 
				AssertConnectionIsOpen ();
				AssertObjectNotDisposed ();
				throw new NotImplementedException ();
			}
		}

		public OracleType LobType {
			get { return type; }
		}

		public override long Position {
			get { 
				AssertConnectionIsOpen ();
				AssertObjectNotDisposed ();
				return position;
			}
			set {
				AssertConnectionIsOpen ();
				AssertObjectNotDisposed ();
				position = value;
			}
		}

		public object Value {
			get { 
				AssertObjectNotDisposed ();
				if (IsNull)
					return DBNull.Value;
				
				byte[] buffer = null;

				int len = (int) Length;
				if (len == 0) {
					// LOB is not Null, but it is Empty
					if (LobType == OracleType.Clob)
						return "";
					else // OracleType.Blob
						return new byte[0];
				}

				if (LobType == OracleType.Clob) {
					buffer = new byte [len];
					Read (buffer, 0, len);
					UnicodeEncoding encoding = new UnicodeEncoding ();
					return encoding.GetString (buffer);
				}
				else {
					// OracleType.Blob
					buffer = new byte [len];
					Read (buffer, 0, len);
					return buffer;
				}
			}
		}

		#endregion // Properties

		#region Methods

		[MonoTODO]
		public void Append (OracleLob source) {
			if (source.IsNull)
				throw new ArgumentNullException ();
			if (Connection.State == ConnectionState.Closed)
				throw new InvalidOperationException ();
			throw new NotImplementedException ();
		}

		void AssertAmountIsEven (long amount, string argName) {
			if (amount % 2 == 1)
				throw new ArgumentOutOfRangeException ("CLOB and NCLOB parameters require even number of bytes for this argument.");
		}

		void AssertAmountIsValid (long amount, string argName) {
			if (amount > UInt32.MaxValue)
				throw new ArgumentOutOfRangeException ("Argument too big.");
			if (LobType == OracleType.Clob || LobType == OracleType.NClob)
				AssertAmountIsEven (amount, argName);
		}

		void AssertConnectionIsOpen () {
			if (connection.State == ConnectionState.Closed)
				throw new InvalidOperationException ("Invalid operation. The connection is closed.");
		}

		void AssertObjectNotDisposed () {
			if (!isOpen)
				throw new ObjectDisposedException ("OracleLob");
		}

		void AssertTransactionExists () {
//			if (connection.Transaction == null)
//				throw new InvalidOperationException ("Modifying a LOB requires that the connection be transacted.");
			throw new NotImplementedException ();
		}

		public void BeginBatch () {
			BeginBatch (OracleLobOpenMode.ReadOnly);
		}

		public void BeginBatch (OracleLobOpenMode mode) {
			AssertConnectionIsOpen ();
			AssertObjectNotDisposed ();

			isBatched = true;
		}

		[MonoTODO]
		public object Clone () {
			throw new NotImplementedException ();
		}

		[MonoTODO]
		public override void Close () {
			isOpen = false;
		}

		public long CopyTo (OracleLob destination) {
			return CopyTo (0, destination, 0, Length);
		}

		public long CopyTo (OracleLob destination, long destinationOffset) {
			return CopyTo (0, destination, destinationOffset, Length);
		}

		public long CopyTo (long sourceOffset, OracleLob destination, long destinationOffset, long amount) {
			if (destination.IsNull)
				throw new ArgumentNullException ();

			AssertAmountIsValid (sourceOffset, "sourceOffset");
			AssertAmountIsValid (destinationOffset, "destinationOffset");
			AssertAmountIsValid (amount, "amount");
			AssertTransactionExists ();
			AssertConnectionIsOpen ();

			throw new NotImplementedException ();
		}

		[MonoTODO]
		public void Dispose () {
			throw new NotImplementedException ();
		}

		public void EndBatch () {
			AssertConnectionIsOpen ();
			AssertObjectNotDisposed ();

			isBatched = false;
		}

		public long Erase () {
			return Erase (0, Length);
		}

		public long Erase (long offset, long amount) {
			if (offset < 0 || amount < 0)
				throw new ArgumentOutOfRangeException ("Must be a positive value.");
			if (offset + amount > Length)
				throw new ArgumentOutOfRangeException ();

			AssertAmountIsValid (offset, "offset");
			AssertAmountIsValid (amount, "amount");

			throw new NotImplementedException ();
		}

		public override void Flush () {
			// No-op
		}

		public override int Read (byte[] buffer, int offset, int count) {
			if (buffer == null)
				throw new ArgumentNullException ();

			AssertAmountIsValid (offset, "offset");
			AssertAmountIsValid (count, "count");
			AssertConnectionIsOpen ();
			AssertObjectNotDisposed ();

			throw new NotImplementedException ();

			int bytesRead;
			byte[] output = new byte[count];

			output.CopyTo (buffer, offset);
			position += bytesRead;
			return bytesRead;
		}

		[MonoTODO]
		public override long Seek (long offset, SeekOrigin origin) {
			long newPosition = position;

			switch (origin) {
				case SeekOrigin.Begin:
					newPosition = offset;
					break;
				case SeekOrigin.Current:
					newPosition += offset;
					break;
				case SeekOrigin.End:
					newPosition = Length - offset;
					break;
			}

			if (newPosition > Length)
				throw new ArgumentOutOfRangeException ();

			position = newPosition;
			return position;
		}

		[MonoTODO]
		public override void SetLength (long value) {
			AssertAmountIsValid (value, "value");
			AssertTransactionExists ();
			AssertConnectionIsOpen ();
			AssertObjectNotDisposed ();

			throw new NotImplementedException ();

			length = value;
		}

		public override void Write (byte[] buffer, int offset, int count) {
			if (buffer == null)
				throw new ArgumentNullException ("Buffer is null.");
			if (offset < 0 || count < 0)
				throw new ArgumentOutOfRangeException ("Must be a positive value.");
			if (offset + count > buffer.Length)
				throw new ArgumentOutOfRangeException ("The offset and count values specified exceed the buffer provided.");
			AssertAmountIsValid (offset, "offset");
			AssertAmountIsValid (count, "count");
			AssertTransactionExists ();
			AssertConnectionIsOpen ();
			AssertObjectNotDisposed ();

			byte[] value = null;
			if (offset + count == buffer.Length && offset == 0)
				value = buffer;
			else {
				value = new byte[count];
				Array.Copy (buffer, offset, value, 0, count);
			}

			throw new NotImplementedException ();

//			position += locator.Write (value, (uint) Position, (uint) value.Length, LobType);
		}

		#endregion // Methods
	}
}