1
/****************************************************************************
3
| Copyright (c) 2007 Novell, Inc.
6
| This program is free software; you can redistribute it and/or
7
| modify it under the terms of version 2 of the GNU General Public License as
8
| published by the Free Software Foundation.
10
| This program is distributed in the hope that it will be useful,
11
| but WITHOUT ANY WARRANTY; without even the implied warranty of
12
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
| GNU General Public License for more details.
15
| You should have received a copy of the GNU General Public License
16
| along with this program; if not, contact Novell, Inc.
18
| To contact Novell about this file by physical or electronic mail,
19
| you may find current contact information at www.novell.com
22
|***************************************************************************/
26
using System.Collections;
28
using Simias.Storage.Provider;
29
using System.Runtime.InteropServices;
31
namespace Simias.Storage.Provider.Fs
34
/// Summary description for FsObjectIterator.
36
public class FsResultSet : MarshalByRefObject, IResultSet
38
private bool AlreadyDisposed = false;
43
/// Creates a resultset from the queue.
45
/// <param name="queue"></param>
46
public FsResultSet(Queue queue)
49
count = resultQ.Count;
52
#region IObjectIterator Members
55
/// Method to return the next set of objects.
56
/// All the objects that can fit in the buffer will be returned.
57
/// returns false when no more objects exist.
59
/// <param name="buffer">Buffer used to return the objects.</param>
60
/// <returns>true - objects returned. false - no more objects</returns>
61
public int GetNext(ref char[] buffer)
63
if (AlreadyDisposed || resultQ.Count == 0)
69
int length = buffer.Length;
71
string startListTag = "<" + XmlTags.ObjectListTag + ">";
72
string endListTag = "</" + XmlTags.ObjectListTag + ">";
73
if (length > startListTag.Length)
75
int stringLen = startListTag.Length;
76
startListTag.CopyTo(0, buffer, offset, stringLen);
79
// Save space for the end tag.
80
length -= endListTag.Length;
82
while (resultQ.Count != 0 && length > 0)
84
string objectXml = (string)resultQ.Peek();
85
stringLen = objectXml.Length;
86
if (length > stringLen)
89
objectXml.CopyTo(0, buffer, offset, stringLen);
95
// We are out of space.
99
endListTag.CopyTo(0, buffer, offset, endListTag.Length);
105
return buffer.Length - length;
110
/// Property to get the count of available objects.
131
#region IDisposable Members
134
/// Method to cleanup any file system resources held.
136
public void Dispose()
138
AlreadyDisposed = true;