Right you are. I was thinking in a completely different context, but this will freak if the optional ones (which is only the last two) are omitted. They'll need to be bounds checked.

Sorry about that.

- Brett

On 15/09/2006, at 8:33 PM, Kenney Westerhof wrote:



Carlos Sanchez wrote:
Fixed the loop and reopened issue
On 9/14/06, Brett Porter <[EMAIL PROTECTED]> wrote:
I was referring to the table elements in the JSP, but I'll also note
that the while loop and switch below are unnecessary.

second = cronEx[0];
minute = cronEx[1];

etc.


Not entirely - if you consider the last fields of the expression optional then this is the cleanest solution. Otherwise you'd have to write an if statement for each assignment.

I assume that right now the cronEx arrays' length is checked to prevent IndexOutOfBoundsExceptions?

-- Kenney

- Brett

On 15/09/2006, at 9:23 AM, Brett Porter wrote:

> This suffers the same limitations that were originally found on the
> same patch for archiva. Are you sure this is the latest?
>
> On 15/09/2006, at 3:36 AM, [EMAIL PROTECTED] wrote:
>
>> +
>> +                String[] cronEx = schedule.getCronExpression
>> ().split( " " );
>> +                int i = 0;
>> +                while ( i < cronEx.length )
>> +                {
>> +                    switch( i )
>> +                    {
>> +                        case 0 : second = cronEx[i]; break;
>> +                        case 1 : minute = cronEx[i]; break;
>> +                        case 2 : hour = cronEx[i]; break;
>> +                        case 3 : dayOfMonth = cronEx[i]; break;
>> +                        case 4 : month = cronEx[i]; break;
>> +                        case 5 : dayOfWeek = cronEx[i]; break;
>> +                        case 6 : year = cronEx[i]; break;
>> +                    }
>> +                    i++;
>> +                }
>> +
>>

Reply via email to