String[] tokens = cronExpression.split( delims );
if ( tokens.length >= 6 ) {
String dayOfWeekTokens = tokens[5];
tokens = dayOfWeekTokens.split( "," ); //$NON-NLS-1$
if ( ( tokens.length > 1 ) || !( tokens[0].equals( "*" ) || tokens[0].equals( "?" ) ) ) { //$NON-NLS-1$ //$NON-NLS-2$
RecurrenceList dayOfWeekList = null;
for ( String token : tokens ) {
if ( listPattern.matcher( token ).matches() ) {
if ( dayOfWeekList == null ) {
dayOfWeekList = new RecurrenceList();
}
dayOfWeekList.getValues().add( Integer.parseInt( token ) );
} else {
if ( dayOfWeekList != null ) {
dayOfWeekRecurrence.add( dayOfWeekList );
dayOfWeekList = null;
}
if ( sequencePattern.matcher( token ).matches() ) {
String[] days = token.split( "-" ); //$NON-NLS-1$
dayOfWeekRecurrence.add( new SequentialRecurrence( Integer.parseInt( days[0] ), Integer
.parseInt( days[1] ) ) );
} else if ( intervalPattern.matcher( token ).matches() ) {
String[] days = token.split( "/" ); //$NON-NLS-1$
dayOfWeekRecurrence.add( new IncrementalRecurrence( Integer.parseInt( days[0] ), Integer
.parseInt( days[1] ) ) );
} else if ( qualifiedDayPattern.matcher( token ).matches() ) {
String[] days = token.split( "#" ); //$NON-NLS-1$
dayOfWeekRecurrence
.add( new QualifiedDayOfWeek( Integer.parseInt( days[1] ), Integer.parseInt( days[0] ) ) );
} else if ( lastDayPattern.matcher( token ).matches() ) {
DayOfWeek dayOfWeek =
DayOfWeek.values()[( Integer.parseInt( token.substring( 0, token.length() - 1 ) ) - 1 ) % 7];
dayOfWeekRecurrence.add( new QualifiedDayOfWeek( DayOfWeekQualifier.LAST, dayOfWeek ) );
} else if ( dayOfWeekRangePattern.matcher( token ).matches() ) {
String[] days = token.split( "-" ); //$NON-NLS-1$
int start = DayOfWeek.valueOf( days[0] ).ordinal();
int finish = DayOfWeek.valueOf( days[1] ).ordinal();
dayOfWeekRecurrence.add( new SequentialRecurrence( start, finish ) );
} else {
dayOfWeekList = new RecurrenceList();
dayOfWeekList.getValues().add( DayOfWeek.valueOf( token ).ordinal() );
dayOfWeekRecurrence.add( dayOfWeekList );
dayOfWeekList = null;
// } else {
// throw new IllegalArgumentException(Messages.getInstance().getErrorString(
// "ComplexJobTrigger.ERROR_0001_InvalidCronExpression")); //$NON-NLS-1$