public static string ReplaceNoDollarVars(string str, Net.Vpc.Upa.Impl.Util.Converter <string, string> varConverter) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); { bool javaExprSupported = true; if (javaExprSupported) { Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern p = new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern("\\{[^\\{\\}]*\\}"); Net.Vpc.Upa.Impl.Util.Regexp.PortablePatternMatcher m = p.Matcher(str == null ? "" : str); while (m.Find()) { string g = m.Group(0); string v = g.Substring(1, (g).Length - 1); sb.Append(m.Replace(varConverter.Convert(v))); } sb.Append(m.Tail()); return(sb.ToString()); } } int i = 0; while (i >= 0 && i < (str).Length) { int j = str.IndexOf("{", i); if (j < 0) { sb.Append(str.Substring(i)); i = -1; } else { sb.Append(str.Substring(i, j)); int k = str.IndexOf("}", j + 1); if (k < 0) { sb.Append(varConverter.Convert(str.Substring(j + 1))); i = -1; } else { sb.Append(varConverter.Convert(str.Substring(j + 1, k))); i = k + 1; } } } return(sb.ToString()); }
public virtual Net.Vpc.Upa.Impl.Persistence.Connection.DefaultConnectionProfileData ParseDefaultConnectionProfileData(string connectionString) { //"derbyAsProduct#v12.5:defaultAsDriver#v8.699://helloAsServer:988AsPort/worldAsPath/anyThing?a=hello&b=titi;a=6;b=8" Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern pattern = new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern("^([^:#;]+)(#([^:;]+))?(:([^:#;]+)(#([^:;]+))?)?://((([^/:;]+)(:([^/:;]+))?)/)?([^;]*)([;](.*))?$"); Net.Vpc.Upa.Impl.Util.Regexp.PortablePatternMatcher matcher = pattern.Matcher(connectionString); bool matchFound = matcher.Find(); if (matchFound) { Net.Vpc.Upa.Impl.Persistence.Connection.DefaultConnectionProfileData d = new Net.Vpc.Upa.Impl.Persistence.Connection.DefaultConnectionProfileData(); d.databaseProductName = matcher.Group(1); d.databaseProductVersion = matcher.Group(3); d.connectionDriverName = matcher.Group(5); d.connectionDriverVersion = matcher.Group(7); d.server = matcher.Group(10); d.port = matcher.Group(12); d.pathAndName = matcher.Group(13); d.paramsString = matcher.Group(15); return(d); } return(null); }