long report_date = reports[i].theReportDate; int day = convertTimeToDay(report_date);  if (day < 0) { day = 0; } ordered_list[day] = reports[i].theQuantity; if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "getTimeOrderedReportedLevels(), Report day is "+day+ "("+TimeUtils.dateString(report_date)+"), Value is: "+ordered_list[day]);
long report_date = reports[i].theReportDate; int day = convertTimeToDay(report_date);  if (day < 0) { day = 0; } ordered_list[day] = reports[i].theQuantity; if (logger.isDebugEnabled()) { logger.debug("getTimeOrderedReportedLevels(), Report day is " + day + "(" + TimeUtils.dateString(report_date) + "), Value is: " + ordered_list[day]); }
  private double[]  getTimeOrderedReportedLevels() {    double ordered_list[];    InventoryReport[] reports;    synchronized (this) {   // Must be synchronized so reports cannot change while we process them      List list = getInventoryReportHistory();      int size = list.size();      reports = (InventoryReport[]) list.toArray(new InventoryReport[size]);    }    // No Reports - use PG for initial inventory level    if (reports.length == 0) {      ordered_list = new double[1];      ordered_list[0] = getDouble(myPG_.getInitialLevel());      //  	    if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "getTimeOrderedReportedLevels(), List is empty.");    } else {      //  	    if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "getTimeOrderedReportedLevels(), Sorting Report list.");      // Sort the Reports by time in ascending order      // Yah, it's inefficient but it's only a few lines of code and there should never      // be more than 5 items in this list      java.util.Arrays.sort(reports, new Comparator() {	  public int compare(Object o1, Object o2) {	    InventoryReport r1 = (InventoryReport) o1;	    InventoryReport r2 = (InventoryReport) o2;	    long diff = r1.theReportDate - r2.theReportDate;	    if (diff < 0L) return -1;	    if (diff > 0L) return  1;	    return 0;	  }	});      long latest = reports[reports.length - 1].theReportDate;      // create a double[] containing inventory levels indexed by day      int reportDay = convertTimeToDay(latest);      int len = reportDay + 1;      if (len <= 0) {	len = 1;      }      ordered_list = new double[len];      java.util.Arrays.fill(ordered_list, Double.NaN);      ordered_list[0] = getDouble(myPG_.getInitialLevel());      for (int i = 0, n = reports.length; i < n; i++) {	long report_date = reports[i].theReportDate;	int day = convertTimeToDay(report_date);	// Last Report that was received before or on day 0 becomes initial value	if (day < 0) {	  day = 0;	}	ordered_list[day] = reports[i].theQuantity;	if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "getTimeOrderedReportedLevels(), Report day is "+day+						 "("+TimeUtils.dateString(report_date)+"), Value is: "+ordered_list[day]);      }    }    return ordered_list;  }