Пример #1
0
 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);
 }
Пример #2
0
 public PatternListLibNameFilter(string[] filter)
 {
     if (filter != null)
     {
         patternStrings = new string[filter.Length];
         patterns       = new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern[filter.Length];
         for (int i = 0; i < filter.Length; i++)
         {
             string f = filter[i];
             if (f != null)
             {
                 f = f.Trim();
                 if ((f).Length == 0)
                 {
                     f = null;
                 }
             }
             patternStrings[i] = f;
             if (f != null)
             {
                 patterns[i] = new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern(Convert(f));
             }
         }
     }
 }
Пример #3
0
        public SimpexpStringFilter(string patternString, bool nullIsEmpty, bool ignoreCase)
        {
            this.patternString = (nullIsEmpty && patternString == null) ? "" : patternString;
            string pattern = Net.Vpc.Upa.Impl.Util.StringUtils.SimpexpToRegexp(patternString, Net.Vpc.Upa.Impl.Util.PatternType.DOT_PATH);

            this.pattern     = this.patternString == null ? null : new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern(ignoreCase ? pattern.ToLower() : pattern);
            this.nullIsEmpty = nullIsEmpty;
            this.ignoreCase  = ignoreCase;
        }
Пример #4
0
        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());
        }
Пример #5
0
 public RegexpStringFilter(string patternString, bool nullIsEmpty, bool ignoreCase)
 {
     this.patternString = (nullIsEmpty && patternString == null) ? "" : patternString;
     this.ignoreCase    = ignoreCase;
     if (patternString != null)
     {
         if (ignoreCase)
         {
             this.pattern = new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern(patternString.ToLower());
         }
         else
         {
             this.pattern = new Net.Vpc.Upa.Impl.Util.Regexp.PortablePattern(patternString);
         }
     }
     this.nullIsEmpty = nullIsEmpty;
     this.ignoreCase  = ignoreCase;
 }
Пример #6
0
        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);
        }