/**
  * Turns an interval into milliseconds./
  *
  * @param interval the interval.
  * @return the milliseconds.
  */
 private static long toIntervalMillis(String interval) {
   TimeUnit2 units = TimeUnit2.MINUTES;
   interval = interval.toLowerCase();
   if (interval.endsWith("h")) {
     units = TimeUnit2.HOURS;
     interval = StringUtils.removeEnd(interval, "h");
   }
   if (interval.endsWith("m")) {
     interval = StringUtils.removeEnd(interval, "m");
   } else if (interval.endsWith("d")) {
     units = TimeUnit2.DAYS;
     interval = StringUtils.removeEnd(interval, "d");
   } else if (interval.endsWith("ms")) {
     units = TimeUnit2.SECONDS;
     interval = StringUtils.removeEnd(interval, "ms");
   } else if (interval.endsWith("s")) {
     units = TimeUnit2.SECONDS;
     interval = StringUtils.removeEnd(interval, "s");
   }
   long value = 0;
   try {
     value = Long.parseLong(interval);
   } catch (NumberFormatException e) {
     value = 1;
   }
   return Math.min(
       TimeUnit2.DAYS.toMillis(30),
       Math.max(TimeUnit2.MINUTES.toMillis(1), units.toMillis(value)));
 }
 /**
  * Returns the interval between indexing.
  *
  * @return the interval between indexing.
  */
 @SuppressWarnings("unused") // used by Jelly EL
 public String getInterval() {
   if (interval < TimeUnit2.SECONDS.toMillis(1)) {
     return Long.toString(interval) + "ms";
   }
   if (interval < TimeUnit2.MINUTES.toMillis(1)) {
     return Long.toString(TimeUnit2.MILLISECONDS.toSeconds(interval)) + "s";
   }
   if (interval < TimeUnit2.HOURS.toMillis(1)) {
     return Long.toString(TimeUnit2.MILLISECONDS.toMinutes(interval)) + "m";
   }
   if (interval < TimeUnit2.DAYS.toMillis(1)) {
     return Long.toString(TimeUnit2.MILLISECONDS.toHours(interval)) + "h";
   }
   return Long.toString(TimeUnit2.MILLISECONDS.toDays(interval)) + "d";
 }
Exemple #3
0
 public Downloadable(String id, String url) {
   this(id, url, TimeUnit2.DAYS.toMillis(1));
 }