public static System.Collections.Generic.IList <string> ParseVarsList(string s) { System.Collections.Generic.IList <string> vars = new System.Collections.Generic.List <string>(); Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern p = new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern("\\$\\{[a-zA-Z]+\\w*\\}"); Net.Vpc.Upa.Impl.Util.Regexp.PortablePatternMatcher m = p.Matcher(s); while (m.Find()) { int n = 0; for (int i = m.Start() - 1; i >= 0 && s[i] == '\\'; i--) { n++; } if (n % 2 != 0) { continue; } string var = s.Substring(m.Start() + 2, m.End() - 1); // if (!vars.contains(var)) { vars.Add(var); } // } // if (!vars.isEmpty()) { // return vars; // } return(vars); }
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); }