Beispiel #1
0
 public ISortedSet TailSet(object limit)
 {
     ISortedSet newList = new TreeSet();
     int i = 0;
     while ((i < Count) && (comparator.Compare(this[i], limit) < 0))
     {
         i++;
     }
     for (; i < Count; i++)
     {
         newList.Add(this[i]);
     }
     return newList;
 }
        protected void BuildExpression(string expression)
        {
            expressionParsed = true;
            try
            {
                if (seconds == null)
                {
                    seconds = new TreeSet();
                }
                if (minutes == null)
                {
                    minutes = new TreeSet();
                }
                if (hours == null)
                {
                    hours = new TreeSet();
                }
                if (daysOfMonth == null)
                {
                    daysOfMonth = new TreeSet();
                }
                if (months == null)
                {
                    months = new TreeSet();
                }
                if (daysOfWeek == null)
                {
                    daysOfWeek = new TreeSet();
                }
                if (years == null)
                {
                    years = new TreeSet();
                }
                int exprOn = Second;
#if NET_20
                string[] exprsTok = expression.Trim().Split(new char[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
#else
                string[] exprsTok = expression.Trim().Split(new[] {' ', '\t', '\r', '\n'});
#endif
                foreach (string exprTok in exprsTok)
                {
                    string expr = exprTok.Trim();
                    if (expr.Length == 0)
                    {
                        continue;
                    }
                    if (exprOn > Year)
                    {
                        break;
                    }

                    if (exprOn == DayOfMonth && expr.IndexOf('L') != -1 && expr.Length > 1 && expr.IndexOf(",") >= 0)
                    {
                        throw new FormatException(
                            "Support for specifying 'L' and 'LW' with other days of the month is not implemented");
                    }

                    if (exprOn == DayOfWeek && expr.IndexOf('L') != -1 && expr.Length > 1 && expr.IndexOf(",") >= 0)
                    {
                        throw new FormatException(
                            "Support for specifying 'L' with other days of the week is not implemented");
                    }
                    string[] vTok = expr.Split(',');
                    foreach (string v in vTok)
                    {
                        StoreExpressionVals(0, v, exprOn);
                    }
                    exprOn++;
                }
                if (exprOn <= DayOfWeek)
                {
                    throw new FormatException("Unexpected end of expression.");
                }
                if (exprOn <= Year)
                {
                    StoreExpressionVals(0, "*", Year);
                }
                TreeSet dow = GetSet(DayOfWeek);
                TreeSet dom = GetSet(DayOfMonth);

                bool dayOfMSpec = !dom.Contains(NoSpec);
                bool dayOfWSpec = !dow.Contains(NoSpec);
                if (dayOfMSpec && !dayOfWSpec)
                {
                }
                else if (dayOfWSpec && !dayOfMSpec)
                {
                }
                else
                {
                    throw new FormatException(
                        "Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.");
                }
            }
            catch (FormatException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new FormatException(string.Format(CultureInfo.InvariantCulture,
                                                        "Illegal cron expression format ({0})", e));
            }