5 // Arina Itkes <arinai@mainsoft.com>
7 // Copyright (C) 2007 Mainsoft, Inc.
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Collections.Generic;
36 using java.util.regex;
39 namespace System.Text.RegularExpressions
42 public partial class Match : Group
46 GroupCollection _monoGroups;
47 readonly object _monoGroupsLock = new object ();
53 internal Match (Regex regex, IMachine machine, string text, int text_length, int n_groups,
54 int index, int length, int n_caps)
55 : this (regex, machine, new GroupCollection (n_groups), text,
56 text_length, index, length, n_caps) { }
58 internal Match (Regex regex, IMachine machine,
59 GroupCollection groups,
60 string text, int text_length,
61 int index, int length)
62 : this (regex, machine, groups, text, text_length, index, length, 1) { }
64 private Match (Regex regex, IMachine machine,
65 GroupCollection groups,
66 string text, int text_length,
67 int index, int length, int n_caps)
68 : base (text, index, length, n_caps) {
70 this.machine = machine;
71 this.text_length = text_length;
74 groups.SetValue (this, 0);
80 private GroupCollection MonoGroups {
82 lock (_monoGroupsLock) {
83 if (_monoGroups != null)
86 Match monoMatch = regex.GetMonoMachine ().Scan (regex, text, index, index + length);
87 _monoGroups = monoMatch.Groups;
96 internal void FillMonoCaptures (Group group) {
97 group.Captures = MonoGroups [group.GroupNumber].Captures;