Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kirzner <borisk@mono-cvs.ximian.com>2005-05-30 10:45:10 +0400
committerBoris Kirzner <borisk@mono-cvs.ximian.com>2005-05-30 10:45:10 +0400
commitdff86994d0b3a97fa3ca7dd232462390ccb4a1e8 (patch)
treed2b1b84a5901c90e0499b2b92fd31243b43b7adf /mcs/class/System.Data/System.Data.Configuration.jvm
parent10de350fc51c8cd46091ebb254dfc1b0474b73d6 (diff)
Added files and folders for TARGET_JVM code base
svn path=/trunk/mcs/; revision=45180
Diffstat (limited to 'mcs/class/System.Data/System.Data.Configuration.jvm')
-rw-r--r--mcs/class/System.Data/System.Data.Configuration.jvm/GlobalConfig.cs51
-rw-r--r--mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolutionSectionHandler.cs79
-rw-r--r--mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolver.cs65
-rw-r--r--mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolversCollection.cs84
4 files changed, 279 insertions, 0 deletions
diff --git a/mcs/class/System.Data/System.Data.Configuration.jvm/GlobalConfig.cs b/mcs/class/System.Data/System.Data.Configuration.jvm/GlobalConfig.cs
new file mode 100644
index 00000000000..27decd252a3
--- /dev/null
+++ b/mcs/class/System.Data/System.Data.Configuration.jvm/GlobalConfig.cs
@@ -0,0 +1,51 @@
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+using System.Collections.Specialized;
+
+namespace System.Data.Configuration {
+
+ internal enum BooleanSetting {
+ False,
+ True,
+ NotSet
+ }
+
+ internal sealed class Switches {
+
+ private Switches() {}
+
+ const string SwitchesSection = "system.data/switches";
+ const string PrefetchSchemaConfigName = "JDBC.PrefetchSchema";
+ static readonly string AppDomainPrefetchSchemaConfigName = String.Concat(SwitchesSection, "/", PrefetchSchemaConfigName);
+
+ internal static BooleanSetting PrefetchSchema {
+ get {
+
+ object value = AppDomain.CurrentDomain.GetData(AppDomainPrefetchSchemaConfigName);
+ if (value != null)
+ return (BooleanSetting)value;
+
+ BooleanSetting setting = BooleanSetting.NotSet;
+
+ NameValueCollection switches = (NameValueCollection)ConfigurationSettings.GetConfig(SwitchesSection);
+ if (switches != null) {
+ string strVal = (string)switches[PrefetchSchemaConfigName];
+ if (strVal != null) {
+ try {
+ setting = Boolean.Parse(strVal) ? BooleanSetting.True : BooleanSetting.False;
+ }
+ catch (Exception e) {
+ throw new ConfigurationException(e.Message, e);
+ }
+ }
+ }
+
+ //lock(AppDomainPrefetchSchemaConfigName)
+ AppDomain.CurrentDomain.SetData(AppDomainPrefetchSchemaConfigName, setting);
+
+ return setting;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolutionSectionHandler.cs b/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolutionSectionHandler.cs
new file mode 100644
index 00000000000..5a6033755c1
--- /dev/null
+++ b/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolutionSectionHandler.cs
@@ -0,0 +1,79 @@
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+
+namespace System.Data.Configuration {
+ class ObjectNameResolutionSectionHandler : IConfigurationSectionHandler {
+ public virtual object Create (object parent, object configContext, XmlNode section) {
+ if (section.Attributes != null && section.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", section);
+
+ ObjectNameResolversCollection col = new ObjectNameResolversCollection(parent as ObjectNameResolversCollection);
+
+ XmlNodeList resolvers = section.ChildNodes;
+ foreach (XmlNode child in resolvers) {
+ XmlNodeType ntype = child.NodeType;
+ if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
+ continue;
+
+ if (ntype != XmlNodeType.Element)
+ HandlersUtil.ThrowException ("Only elements allowed", child);
+
+ string dbname = HandlersUtil.ExtractAttributeValue ("dbname", child,false,true);
+ string match = HandlersUtil.ExtractAttributeValue ("match", child);
+ string pri = HandlersUtil.ExtractAttributeValue ("priority", child);
+
+ ObjectNameResolver resolver = new ObjectNameResolver(dbname, match, int.Parse(pri));
+ col.Add(resolver);
+ }
+
+ col.Sort();
+
+ return col;
+ }
+ }
+
+ internal sealed class HandlersUtil {
+ private HandlersUtil () {
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node) {
+ return ExtractAttributeValue (attKey, node, false);
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node, bool optional) {
+ return ExtractAttributeValue (attKey, node, optional, false);
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node, bool optional,
+ bool allowEmpty) {
+ if (node.Attributes == null) {
+ if (optional)
+ return null;
+
+ ThrowException ("Required attribute not found: " + attKey, node);
+ }
+
+ XmlNode att = node.Attributes.RemoveNamedItem (attKey);
+ if (att == null) {
+ if (optional)
+ return null;
+ ThrowException ("Required attribute not found: " + attKey, node);
+ }
+
+ string value = att.Value;
+ if (!allowEmpty && value == String.Empty) {
+ string opt = optional ? "Optional" : "Required";
+ ThrowException (opt + " attribute is empty: " + attKey, node);
+ }
+
+ return value;
+ }
+
+ static internal void ThrowException (string msg, XmlNode node) {
+ if (node != null && node.Name != String.Empty)
+ msg = msg + " (node name: " + node.Name + ") ";
+ throw new ConfigurationException (msg, node);
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolver.cs b/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolver.cs
new file mode 100644
index 00000000000..447d79bbbd5
--- /dev/null
+++ b/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolver.cs
@@ -0,0 +1,65 @@
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+using System.Text.RegularExpressions;
+
+namespace System.Data.Configuration {
+ sealed class ObjectNameResolver : IComparable {
+ string _dbname;
+ int _priority;
+ Regex _regex;
+
+ public ObjectNameResolver(string dbname, string match, int priority) {
+ _dbname = dbname;
+ _regex = new Regex(match, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);
+
+ _priority = priority;
+ }
+
+ public ObjectNameResolver(Regex regex) {
+ _regex = regex;
+ _dbname = null;
+ _priority = int.MaxValue;
+ }
+
+ public string DbName {
+ get {
+ return _dbname;
+ }
+ }
+
+ public static string GetCatalog(Match match) {
+ return GetCapture(match, "CATALOG");
+ }
+
+ public static string GetSchema(Match match) {
+ return GetCapture(match, "SCHEMA");
+ }
+
+ public static string GetName(Match match) {
+ return GetCapture(match, "NAME");
+ }
+
+ public Match Match(string expression) {
+ return _regex.Match(expression.Trim());
+ }
+
+ static string GetCapture(Match match, string captureName) {
+ Group g = match.Groups[captureName];
+ if (!g.Success)
+ return String.Empty;
+
+ return g.Value.Trim();
+ }
+
+ #region IComparable Members
+
+ public int CompareTo(object obj) {
+ // TODO: Add ObjectNameResolver.CompareTo implementation
+ return _priority.CompareTo(((ObjectNameResolver)obj)._priority);
+ }
+
+ #endregion
+
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolversCollection.cs b/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolversCollection.cs
new file mode 100644
index 00000000000..3f4f19c4f6e
--- /dev/null
+++ b/mcs/class/System.Data/System.Data.Configuration.jvm/ObjectNameResolversCollection.cs
@@ -0,0 +1,84 @@
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+using System.Text.RegularExpressions;
+
+namespace System.Data.Configuration {
+ sealed class ObjectNameResolversCollection : IEnumerable, ICollection {
+
+ ArrayList _resolvers;
+
+ #region ctors
+
+ internal ObjectNameResolversCollection(ObjectNameResolversCollection parent) {
+ _resolvers = new ArrayList();
+
+ if (parent != null)
+ _resolvers.AddRange(parent);
+ }
+
+ #endregion
+
+ #region methods
+
+ internal void Add(ObjectNameResolver value) {
+ _resolvers.Add(value);
+ }
+
+ internal void Sort() {
+ _resolvers.Sort();
+ }
+
+ #endregion
+
+ #region props
+
+ internal ObjectNameResolver this[int index] {
+ get {
+ return (ObjectNameResolver)_resolvers[index];
+ }
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ public IEnumerator GetEnumerator() {
+ // TODO: Add ObjectNameResolversCollection.GetEnumerator implementation
+ return _resolvers.GetEnumerator();
+ }
+
+ #endregion
+
+ #region ICollection Members
+
+ public bool IsSynchronized {
+ get {
+ // TODO: Add ObjectNameResolversCollection.IsSynchronized getter implementation
+ return _resolvers.IsSynchronized;
+ }
+ }
+
+ public int Count {
+ get {
+ // TODO: Add ObjectNameResolversCollection.Count getter implementation
+ return _resolvers.Count;
+ }
+ }
+
+ public void CopyTo(Array array, int index) {
+ // TODO: Add ObjectNameResolversCollection.CopyTo implementation
+ _resolvers.CopyTo(array, index);
+ }
+
+ public object SyncRoot {
+ get {
+ // TODO: Add ObjectNameResolversCollection.SyncRoot getter implementation
+ return _resolvers.SyncRoot;
+ }
+ }
+
+ #endregion
+ }
+
+} \ No newline at end of file