1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 *******************************************************************************/
24 // Novell.Directory.Ldap.MessageVector.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
34 namespace Novell.Directory.Ldap
37 /// <summary> The <code>MessageVector</code> class implements additional semantics
38 /// to Vector needed for handling messages.
41 class MessageVector:System.Collections.IList
43 private readonly System.Collections.ArrayList _innerList;
44 /// <summary>Returns an array containing all of the elements in this MessageVector.
45 /// The elements returned are in the same order in the array as in the
46 /// Vector. The contents of the vector are cleared.
49 /// <returns> the array containing all of the elements.
51 internal System.Object[] ObjectArray
59 System.Object[] results = ToArray();
67 internal MessageVector(int cap, int incr)
69 _innerList = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(cap));
73 /// <summary> Finds the Message object with the given MsgID, and returns the Message
74 /// object. It finds the object and returns it in an atomic operation.
77 /// <param name="msgId">The msgId of the Message object to return
80 /// <returns> The Message object corresponding to this MsgId.
82 /// @throws NoSuchFieldException when no object with the corresponding
83 /// value for the MsgId field can be found.
86 internal Message findMessageById(int msgId)
91 for (int i = 0; i < Count; i++)
93 if ((msg = (Message) this[i]) == null)
95 throw new System.FieldAccessException();
97 if (msg.MessageID == msgId)
102 throw new System.FieldAccessException();
106 #region ArrayList members
\r
107 public object[] ToArray()
\r
109 return _innerList.ToArray();
\r
113 #region IList Members
\r
115 public int Add(object value)
\r
117 return _innerList.Add(value);
\r
120 public void Clear()
\r
122 _innerList.Clear();
\r
125 public bool Contains(object value)
\r
127 return _innerList.Contains(value);
\r
130 public int IndexOf(object value)
\r
132 return _innerList.IndexOf(value);
\r
135 public void Insert(int index, object value)
\r
137 _innerList.Insert(index, value);
\r
140 public bool IsFixedSize
\r
142 get { return _innerList.IsFixedSize; }
\r
145 public bool IsReadOnly
\r
147 get { return _innerList.IsReadOnly; }
\r
150 public void Remove(object value)
\r
152 _innerList.Remove(value);
\r
155 public void RemoveAt(int index)
\r
157 _innerList.RemoveAt(index);
\r
160 public object this[int index]
\r
164 return _innerList[index];
\r
168 _innerList[index] = value;
\r
174 #region ICollection Members
\r
176 public void CopyTo(Array array, int index)
\r
178 _innerList.CopyTo(array, index);
\r
183 get { return _innerList.Count; }
\r
186 public bool IsSynchronized
\r
188 get { return _innerList.IsSynchronized; }
\r
191 public object SyncRoot
\r
193 get { return _innerList.SyncRoot; }
\r
198 #region IEnumerable Members
\r
200 public System.Collections.IEnumerator GetEnumerator()
\r
202 return _innerList.GetEnumerator();
\r