[runtime] Overwrite stacktrace for exception on re-throw. Fixes #1856.
[mono.git] / mcs / class / System.Data / System.Data.Configuration.jvm / ObjectNameResolver.cs
1 // 
2 // System.Data.Configuration.ObjectNameResolver.cs
3 //
4 // Authors:
5 //      Konstantin Triger <kostat@mainsoft.com>
6 //      
7 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
8 //
9
10 //
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:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
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.
29 //\r
30 \r
31 using System.Collections;\r
32 using System.Configuration;\r
33 using System.Xml;\r
34 using System.Text.RegularExpressions;\r
35 \r
36 namespace System.Data.Configuration {\r
37         sealed class ObjectNameResolver : IComparable {\r
38                 string _dbname;\r
39                 int _priority;\r
40                 Regex _regex;\r
41                 \r
42                 public ObjectNameResolver(string dbname, string match, int priority) {\r
43                         _dbname = dbname;\r
44                         _regex = new Regex(match, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);\r
45                         \r
46                         _priority = priority;\r
47                 }\r
48 \r
49                 public ObjectNameResolver(Regex regex) {\r
50                         _regex = regex;\r
51                         _dbname = null;\r
52                         _priority = int.MaxValue;\r
53                 }\r
54 \r
55                 public string DbName {\r
56                         get {\r
57                                 return _dbname;\r
58                         }\r
59                 }\r
60 \r
61                 public static string GetCatalog(Match match) {\r
62                         return GetCapture(match, "CATALOG");\r
63                 }\r
64 \r
65                 public static string GetSchema(Match match) {\r
66                         return GetCapture(match, "SCHEMA");\r
67                 }\r
68 \r
69                 public static string GetName(Match match) {\r
70                         return GetCapture(match, "NAME");\r
71                 }\r
72 \r
73                 public Match Match(string expression) {\r
74                         return _regex.Match(expression.Trim());\r
75                 }\r
76 \r
77                 static string GetCapture(Match match, string captureName) {\r
78                         Group g = match.Groups[captureName];\r
79                         if (!g.Success)\r
80                                 return String.Empty;\r
81 \r
82                         return g.Value.Trim();\r
83                 }\r
84 \r
85                 #region IComparable Members\r
86 \r
87                 public int CompareTo(object obj) {\r
88                         // TODO:  Add ObjectNameResolver.CompareTo implementation\r
89                         return _priority.CompareTo(((ObjectNameResolver)obj)._priority);\r
90                 }\r
91 \r
92                 #endregion\r
93 \r
94         }\r
95 }