2004-05-12 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Wed, 12 May 2004 16:10:07 +0000 (16:10 -0000)
committerDick Porter <dick@acm.org>
Wed, 12 May 2004 16:10:07 +0000 (16:10 -0000)
* GroupCollection.cs:
* MatchCollection.cs:
* CaptureCollection.cs: Moved GroupCollection, MatchCollection and
CaptureCollection so that they no longer inherit from the
non-standard RegexCollectionBase class.  Fixes the API difference.

svn path=/trunk/mcs/; revision=27175

mcs/class/System/System.Text.RegularExpressions/CaptureCollection.cs [new file with mode: 0644]
mcs/class/System/System.Text.RegularExpressions/ChangeLog
mcs/class/System/System.Text.RegularExpressions/GroupCollection.cs [new file with mode: 0644]
mcs/class/System/System.Text.RegularExpressions/MatchCollection.cs [new file with mode: 0644]
mcs/class/System/System.Text.RegularExpressions/collections.cs [deleted file]

diff --git a/mcs/class/System/System.Text.RegularExpressions/CaptureCollection.cs b/mcs/class/System/System.Text.RegularExpressions/CaptureCollection.cs
new file mode 100644 (file)
index 0000000..9ded1e8
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// System.Text.RegularExpressions.CaptureCollection
+//
+// Authors:
+//     Dan Lewis (dlewis@gmx.co.uk)
+//     Dick Porter (dick@ximian.com)
+//
+// (C) 2002 Dan Lewis
+// (C) 2004 Novell, Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.Text.RegularExpressions 
+{
+       [Serializable]
+       public class CaptureCollection: ICollection, IEnumerable
+       {
+               private ArrayList list;
+
+               /* No public constructor */
+               internal CaptureCollection () {
+                       list = new ArrayList ();
+               }
+
+               public virtual int Count {
+                       get {
+                               return(list.Count);
+                       }
+               }
+
+               public bool IsReadOnly {
+                       get {
+                               return(true);
+                       }
+               }
+
+               public virtual bool IsSynchronized {
+                       get {
+                               return(false);
+                       }
+               }
+
+               public Capture this[int i] {
+                       get {
+                               if (i < 0 ||
+                                   i > Count) {
+                                       throw new ArgumentOutOfRangeException ("Index is out of range");
+                               }
+                               
+                               return((Capture)list[i]);
+                       }
+               }
+
+               public virtual object SyncRoot {
+                       get {
+                               return(list);
+                       }
+               }
+
+               public virtual void CopyTo (Array array, int index) {
+                       foreach (object o in list) {
+                               if (index > array.Length) {
+                                       break;
+                               }
+
+                               array.SetValue (o, index++);
+                       }
+               }
+
+               public virtual IEnumerator GetEnumerator () {
+                       return(new Enumerator (list));
+               }
+
+               internal void Add (object o) {
+                       list.Add (o);
+               }
+
+               internal void Reverse () {
+                       list.Reverse ();
+               }
+
+               private class Enumerator: IEnumerator {
+                       private IList list;
+                       private int ptr;
+
+                       public Enumerator (IList list) {
+                               this.list = list;
+                               Reset ();
+                       }
+
+                       public object Current {
+                               get {
+                                       if (ptr >= list.Count) {
+                                               throw new InvalidOperationException ();
+                                       }
+
+                                       return(list[ptr]);
+                               }
+                       }
+
+                       public bool MoveNext () {
+                               if (ptr > list.Count) {
+                                       throw new InvalidOperationException ();
+                               }
+
+                               return(++ptr < list.Count);
+                       }
+
+                       public void Reset () {
+                               ptr = -1;
+                       }
+               }
+       }
+}
+
+               
+               
index 5d7049d4f6509139790bdde45f3a6e2f3737b87d..dd4cbe726621f7657be3daa33cdce6c8e8554cf6 100644 (file)
@@ -1,3 +1,11 @@
+2004-05-12  Dick Porter  <dick@ximian.com>
+
+       * GroupCollection.cs: 
+       * MatchCollection.cs: 
+       * CaptureCollection.cs: Moved GroupCollection, MatchCollection and
+       CaptureCollection so that they no longer inherit from the
+       non-standard RegexCollectionBase class.  Fixes the API difference.
+
 2004-04-19  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * arch.cs:
diff --git a/mcs/class/System/System.Text.RegularExpressions/GroupCollection.cs b/mcs/class/System/System.Text.RegularExpressions/GroupCollection.cs
new file mode 100644 (file)
index 0000000..2c5c151
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// System.Text.RegularExpressions.GroupCollection
+//
+// Authors:
+//     Dan Lewis (dlewis@gmx.co.uk)
+//     Dick Porter (dick@ximian.com)
+//
+// (C) 2002 Dan Lewis
+// (C) 2004 Novell, Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.Text.RegularExpressions 
+{
+       [Serializable]
+       public class GroupCollection: ICollection, IEnumerable
+       {
+               private ArrayList list;
+
+               /* No public constructor */
+               internal GroupCollection () {
+                       list = new ArrayList ();
+               }
+
+               public virtual int Count {
+                       get {
+                               return(list.Count);
+                       }
+               }
+
+               public bool IsReadOnly {
+                       get {
+                               return(true);
+                       }
+               }
+
+               public virtual bool IsSynchronized {
+                       get {
+                               return(false);
+                       }
+               }
+
+               public Group this[int i] {
+                       get {
+                               if (i < list.Count &&
+                                   i >= 0) {
+                                       return((Group)list[i]);
+                               } else {
+                                       return(new Group ());
+                               }
+                       }
+               }
+
+               public Group this[string groupName] {
+                       get {
+                               foreach (object o in list) {
+                                       if (!(o is Match)) {
+                                               continue;
+                                       }
+
+                                       int index = ((Match)o).Regex.GroupNumberFromName (groupName);
+
+                                       if (index != -1) {
+                                               return(this[index]);
+                                       }
+                               }
+
+                               return(new Group ());
+                       }
+               }
+
+               public virtual object SyncRoot {
+                       get {
+                               return(list);
+                       }
+               }
+
+               public virtual void CopyTo (Array array, int index) {
+                       foreach (object o in list) {
+                               if (index > array.Length) {
+                                       break;
+                               }
+
+                               array.SetValue (o, index++);
+                       }
+               }
+
+               public virtual IEnumerator GetEnumerator () {
+                       return(new Enumerator (list));
+               }
+
+               internal void Add (object o) {
+                       list.Add (o);
+               }
+
+               internal void Reverse () {
+                       list.Reverse ();
+               }
+
+               private class Enumerator: IEnumerator {
+                       private IList list;
+                       private int ptr;
+
+                       public Enumerator (IList list) {
+                               this.list = list;
+                               Reset ();
+                       }
+
+                       public object Current {
+                               get {
+                                       if (ptr >= list.Count) {
+                                               throw new InvalidOperationException ();
+                                       }
+
+                                       return(list[ptr]);
+                               }
+                       }
+
+                       public bool MoveNext () {
+                               if (ptr > list.Count) {
+                                       throw new InvalidOperationException ();
+                               }
+
+                               return(++ptr < list.Count);
+                       }
+
+                       public void Reset () {
+                               ptr = -1;
+                       }
+               }
+       }
+}
+
+               
+               
diff --git a/mcs/class/System/System.Text.RegularExpressions/MatchCollection.cs b/mcs/class/System/System.Text.RegularExpressions/MatchCollection.cs
new file mode 100644 (file)
index 0000000..a8eeab5
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// System.Text.RegularExpressions.MatchCollection
+//
+// Authors:
+//     Dan Lewis (dlewis@gmx.co.uk)
+//     Dick Porter (dick@ximian.com)
+//
+// (C) 2002 Dan Lewis
+// (C) 2004 Novell, Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.Text.RegularExpressions 
+{
+       [Serializable]
+       public class MatchCollection: ICollection, IEnumerable
+       {
+               private ArrayList list;
+
+               /* No public constructor */
+               internal MatchCollection () {
+                       list = new ArrayList ();
+               }
+
+               public virtual int Count {
+                       get {
+                               return(list.Count);
+                       }
+               }
+
+               public bool IsReadOnly {
+                       get {
+                               return(true);
+                       }
+               }
+
+               public virtual bool IsSynchronized {
+                       get {
+                               return(false);
+                       }
+               }
+
+               public Match this[int i] {
+                       get {
+                               if (i < 0 ||
+                                   i > Count) {
+                                       throw new ArgumentOutOfRangeException ("Index is out of range");
+                               }
+                               
+                               return((Match)list[i]);
+                       }
+               }
+
+               public virtual object SyncRoot {
+                       get {
+                               return(list);
+                       }
+               }
+
+               public virtual void CopyTo (Array array, int index) {
+                       foreach (object o in list) {
+                               if (index > array.Length) {
+                                       break;
+                               }
+
+                               array.SetValue (o, index++);
+                       }
+               }
+
+               public virtual IEnumerator GetEnumerator () {
+                       return(new Enumerator (list));
+               }
+
+               internal void Add (object o) {
+                       list.Add (o);
+               }
+
+               internal void Reverse () {
+                       list.Reverse ();
+               }
+
+               private class Enumerator: IEnumerator {
+                       private IList list;
+                       private int ptr;
+
+                       public Enumerator (IList list) {
+                               this.list = list;
+                               Reset ();
+                       }
+
+                       public object Current {
+                               get {
+                                       if (ptr >= list.Count) {
+                                               throw new InvalidOperationException ();
+                                       }
+
+                                       return(list[ptr]);
+                               }
+                       }
+
+                       public bool MoveNext () {
+                               if (ptr > list.Count) {
+                                       throw new InvalidOperationException ();
+                               }
+
+                               return(++ptr < list.Count);
+                       }
+
+                       public void Reset () {
+                               ptr = -1;
+                       }
+               }
+       }
+}
+
+               
+               
diff --git a/mcs/class/System/System.Text.RegularExpressions/collections.cs b/mcs/class/System/System.Text.RegularExpressions/collections.cs
deleted file mode 100644 (file)
index f0d648b..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-//\r
-// assembly:   System\r
-// namespace:  System.Text.RegularExpressions\r
-// file:       collections.cs\r
-//\r
-// author:     Dan Lewis (dlewis@gmx.co.uk)\r
-//             (c) 2002\r
-\r
-using System;\r
-using System.Collections;\r
-\r
-namespace System.Text.RegularExpressions {\r
-       public abstract class RegexCollectionBase : ICollection, IEnumerable {\r
-               public int Count {\r
-                       get { return list.Count; }\r
-               }\r
-\r
-               public bool IsReadOnly {\r
-                       get { return true; }    // FIXME\r
-               }\r
-\r
-               public bool IsSynchronized {\r
-                       get { return false; }   // FIXME\r
-               }\r
-\r
-               public object SyncRoot {\r
-                       get { return list; }    // FIXME\r
-               }\r
-\r
-               public void CopyTo (Array array, int index) {\r
-                       foreach (Object o in list) {\r
-                               if (index > array.Length)\r
-                                       break;\r
-                               \r
-                               array.SetValue (o, index ++);\r
-                       }\r
-               }\r
-\r
-               public IEnumerator GetEnumerator () {\r
-                       return new Enumerator (list);\r
-               }\r
-\r
-               // internal methods\r
-\r
-               internal RegexCollectionBase () {\r
-                       list = new ArrayList ();\r
-               }\r
-\r
-               internal void Add (Object o) {\r
-                       list.Add (o);\r
-               }\r
-\r
-               internal void Reverse () {\r
-                       list.Reverse ();\r
-               }\r
-\r
-               // IEnumerator implementation\r
-\r
-               private class Enumerator : IEnumerator {\r
-                       public Enumerator (IList list) {\r
-                               this.list = list;\r
-                               Reset ();\r
-                       }\r
-\r
-                       public object Current {\r
-                               get {\r
-                                       if (ptr >= list.Count)\r
-                                               throw new InvalidOperationException ();\r
-\r
-                                       return list[ptr];\r
-                               }\r
-                       }\r
-\r
-                       public bool MoveNext () {\r
-                               if (ptr > list.Count)\r
-                                       throw new InvalidOperationException ();\r
-                               \r
-                               return ++ ptr < list.Count;\r
-                       }\r
-\r
-                       public void Reset () {\r
-                               ptr = -1;\r
-                       }\r
-\r
-                       private IList list;\r
-                       private int ptr;\r
-               }\r
-\r
-               // protected fields\r
-\r
-               protected ArrayList list;\r
-       }\r
-\r
-       [Serializable]\r
-       public class CaptureCollection : RegexCollectionBase, ICollection, IEnumerable {\r
-               public Capture this[int i] {\r
-                       get { return (Capture)list[i]; }\r
-               }\r
-\r
-               internal CaptureCollection () {\r
-               }\r
-       }\r
-\r
-       [Serializable]\r
-       public class GroupCollection : RegexCollectionBase, ICollection, IEnumerable {\r
-               public Group this[int i] {\r
-                       get { \r
-                               if (i < list.Count && i >= 0) \r
-                                       return (Group)list[i]; \r
-                               else\r
-                                       return new Group ();\r
-                       }\r
-               }\r
-               \r
-               public Group this[string groupName] {\r
-                       get {\r
-                               foreach (object o in list) {\r
-                                       if (!(o is Match))\r
-                                               continue;\r
-\r
-                                       int index = ((Match) o).Regex.GroupNumberFromName (groupName);\r
-                                       if (index != -1)\r
-                                               return this [index];\r
-                               }\r
-\r
-                               return new Group ();\r
-                       }\r
-               }\r
-               \r
-               internal GroupCollection () {\r
-               }\r
-       }\r
-\r
-       [Serializable]\r
-       public class MatchCollection : RegexCollectionBase, ICollection, IEnumerable {\r
-               public virtual Match this[int i] {\r
-                       get { return (Match)list[i]; }\r
-               }\r
-\r
-               internal MatchCollection () {\r
-               }\r
-       }\r
-}\r