ShrinkingLargeProgressMonitor implements LargeProgressMonitor { @Override public void startTask(long totalUnits, String task) { if (totalUnits < 0) throw new IllegalArgumentException("Total works units must be positive."); shift = 33 - Long.numberOfLeadingZeros(totalUnits); if (shift < 0) shift = 0; totalWorked = 0; intTotalWorked = 0; wrapped.startTask((int)(totalUnits >> shift), task); } ShrinkingLargeProgressMonitor(ProgressMonitor wrapped); @Override void subTask(String message); @Override void startTask(long totalUnits, String task); @Override void worked(long workUnits);  }
@Test public void testStartTask() { ShrinkingLargeProgressMonitor pm = new ShrinkingLargeProgressMonitor(new NullProgressMonitor()); pm.startTask(0x7FFFFFFFL, ""); assertEquals("Shift", pm.shift, 0); pm.startTask(0x80000000L, ""); assertEquals("Shift", pm.shift, 1); pm.startTask(0x100000000L, ""); assertEquals("Shift", pm.shift, 2); pm.startTask(0x200000000L, ""); assertEquals("Shift", pm.shift, 3); }