if ( "YEARLY".equals(freq) ){
unit = Calendar.YEAR;
}
println("in bwdms: unit = "+unit);
HashSet result = new HashSet();
for ( Iterator oit = origSet.iterator() ; oit.hasNext() ; ){
Calendar curProtoDate = (Calendar)oit.next();
for ( Iterator it = metaSet.iterator() ; it.hasNext() ; ){
ByDay bd = (ByDay)it.next();
if ( bd.count==0 ){
println("in bwdms: finding all");
// they want all occurrences
ByDay localbd = new ByDay(1,bd.weekday);
Calendar str = Calendar.getInstance();
str.setTime(start);
Calendar hunter = huntDayOfWeek( str , localbd);
// some of the other BYxyz commands may limit the scope of this breeding.
// figure that out here
int localUnit = unit;
boolean needSameMonth = false;
boolean needSameWeek = false;
boolean needSameDay = false;
if ( foundByMonth || "MONTHLY".equals(freq) ) needSameMonth = true;
//if ( foundByMonthDay || foundByWeekNo || foundByYearDay || "WEEKLY".equals(freq) ) needSameWeek = true;
if ( foundByWeekNo || "WEEKLY".equals(freq) ) needSameWeek = true;
if ( foundByMonthDay || foundByYearDay || "DAILY".equals(freq) ) needSameDay = true;
println("nsm "+needSameMonth);
println("nsw "+needSameWeek);
println("nsd "+needSameDay);
while ( hunter.getTime().before(end) ){ //JJHNOTE
if ( hunter.get(Calendar.YEAR) == curProtoDate.get(Calendar.YEAR) ){
if ( !needSameMonth || ( needSameMonth && hunter.get(Calendar.MONTH) == curProtoDate.get(Calendar.MONTH) ) ){
if ( !needSameWeek || ( needSameWeek && hunter.get(Calendar.WEEK_OF_YEAR) == curProtoDate.get(Calendar.WEEK_OF_YEAR)) ){
if ( !needSameDay || ( needSameDay && hunter.get(Calendar.DAY_OF_YEAR) == curProtoDate.get(Calendar.DAY_OF_YEAR)) ){
result.add( hunter.clone() );
}
}
}
}
hunter.add( Calendar.WEEK_OF_YEAR, 1);
}
}
else{
println("in bwdms: finding specific");
// they want a specific count
result.add( huntDayOfWeek(curProtoDate, bd) );
}
}
}
return result;