Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

PCalDayInfo net::sf::linuxorg::pcal::engine::Engine::getDayInfoRecorded ( final Date  date ) [inline, private]

This inner method evaluated the date information for the dates within recorded periods

Parameters:
date- the date being analyzed
Returns:
the day info record or NULL if no data available

Definition at line 313 of file Engine.java.

References avgLength, checkForFutureOvulation(), dateDiff(), dateTypes, net::sf::linuxorg::pcal::engine::DayInfoRecordsFactory::getFertileDayInfo(), getMensPeriodEndDate(), getMensPeriodOvulationDate(), net::sf::linuxorg::pcal::engine::DayInfoRecordsFactory::getNonFertileDayInfo(), getPeriodStartDate(), and net::sf::linuxorg::pcal::engine::DayInfoRecordsFactory::getPregnancyDayInfo().

Referenced by getDayInfo().

                                                              {
            PCalDayInfo info = null;

            // find the starting date of the date's period
            Date periodStartDate = getPeriodStartDate(date, true);
            if(periodStartDate!=null) {                
                  // this is a date in the complete period
                  // this is not a day 1 - we have already checked this
                  int date_type = dateTypes.get(periodStartDate);
                  int day_num = dateDiff(date, periodStartDate);

                  if(date_type == PCAL_TYPE_MENS) {
                        Date periodEndDate = getMensPeriodEndDate(periodStartDate);
                        Date periodOvulationDate = getMensPeriodOvulationDate(periodStartDate);
                        boolean fertileDay = false;
                        int period_length = 0;

                        if(periodEndDate == null) {
                              period_length = avgLength;
                        } else {
                              period_length = dateDiff(periodStartDate, periodEndDate);
                        }
                        // zero means we have no periods statistics
                        int daysTillEnd = (period_length==0)?0:(period_length - day_num);  

                        if(periodOvulationDate == null) {
                              if(daysTillEnd==0) {
                                    // better to say unknown here... this case normally should never happen
                                    fertileDay  = false;
                              } else {
                                    fertileDay = (daysTillEnd < 18) && (daysTillEnd > 11);
                              }
                        } else {
                              if(date.before(periodOvulationDate)) {
                                    // the date is between the cycle start and the ovulation date
                                    int daysTillOvulationEnd = dateDiff(date, periodOvulationDate);
                                    fertileDay = daysTillOvulationEnd < PERIOD_FERTILE_DAYS_COUNT;
                              } else {
                                    // This is definitely non-fertile date
                                    fertileDay = false;
                              }
                        }

                        if(fertileDay) {
                              info = DayInfoRecordsFactory.getFertileDayInfo(day_num);
                        } else {
                              info = DayInfoRecordsFactory.getNonFertileDayInfo(day_num);
                        }
                        if(daysTillEnd == 0) {
                              info.badFeel = (day_num<=enginePreferences.badFeelDaysAfter);
                        } else {
                              info.badFeel = (day_num<=enginePreferences.badFeelDaysAfter)||(daysTillEnd<=enginePreferences.badFeelDaysBefore);
                        }

                  } else 
                        if(date_type == PCAL_TYPE_PREGNANCY) {
                              Date nextDate = startDates.higher(periodStartDate);
                              int nextDateType = dateTypes.get(nextDate);
                              if(((nextDateType == PCAL_TYPE_BIRTH) || 
                                          (nextDateType == PCAL_TYPE_PREGNANCY_INT))
                                          && (day_num <= MAX_PREGNANCY_DAYS)) {
                                    // the pregnancy maybe took longer but still completion was recorded
                                    info = DayInfoRecordsFactory.getPregnancyDayInfo(day_num);
                              } else
                                    if(day_num <= REGULAR_PREGNANCY_DAYS) {
                                          //pregnancy completion was not recorded - actually this is the prediction
                                          info = DayInfoRecordsFactory.getPregnancyDayInfo(day_num);
                                    } else {
                                          // this is a day after the normal pregnancy period
                                          // know nothing
                                          info = DayInfoRecordsFactory.getNonFertileDayInfo(-1);
                                    }
                        } else {
                              // know nothing
                              info = DayInfoRecordsFactory.getNonFertileDayInfo(-1);
                        }
            } else {
                  // we still can say something if the date is followed by the ovulation date
                  Boolean ovulationFound = checkForFutureOvulation(date);

                  if(ovulationFound == null) {
                        // know nothing
                        info = DayInfoRecordsFactory.getNonFertileDayInfo(-1);
                  } else 
                        if(ovulationFound) {
                              // at least we know this is a fertile day
                              info = DayInfoRecordsFactory.getFertileDayInfo(-1);
                        }
            }
            return info;
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index