19 package org.sleuthkit.autopsy.timeline.utils;
 
   21 import com.google.common.collect.ImmutableList;
 
   22 import java.util.ArrayList;
 
   23 import java.util.List;
 
   24 import javax.annotation.concurrent.Immutable;
 
   25 import org.joda.time.DateTime;
 
   26 import org.joda.time.DateTimeFieldType;
 
   27 import org.joda.time.Days;
 
   28 import org.joda.time.Hours;
 
   29 import org.joda.time.Interval;
 
   30 import org.joda.time.Minutes;
 
   31 import org.joda.time.Months;
 
   32 import org.joda.time.Seconds;
 
   33 import org.joda.time.Years;
 
   34 import org.joda.time.format.DateTimeFormat;
 
   35 import org.joda.time.format.DateTimeFormatter;
 
   36 import org.joda.time.format.ISODateTimeFormat;
 
   88     private RangeDivisionInfo(Interval timeRange, 
int periodsInRange, 
TimeUnits periodSize, DateTimeFormatter tickformatter, 
long lowerBound, 
long upperBound) {
 
   89         this.numberOfBlocks = periodsInRange;
 
   90         this.blockSize = periodSize;
 
   91         this.tickFormatter = tickformatter;
 
  112         DateTimeFieldType timeUnit;
 
  116         if (Years.yearsIn(timeRange).isGreaterThan(Years.THREE)) {
 
  117             timeUnit = DateTimeFieldType.year();
 
  118             long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
 
  119             long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
 
  120             return new RangeDivisionInfo(timeRange, Years.yearsIn(timeRange).get(timeUnit.getDurationType()) + 1, 
TimeUnits.
YEARS, ISODateTimeFormat.year(), lower, upper);
 
  121         } 
else if (Months.monthsIn(timeRange).isGreaterThan(Months.THREE)) {
 
  122             timeUnit = DateTimeFieldType.monthOfYear();
 
  123             long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
 
  124             long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
 
  125             return new RangeDivisionInfo(timeRange, Months.monthsIn(timeRange).getMonths() + 1, 
TimeUnits.
MONTHS, DateTimeFormat.forPattern(
"YYYY'-'MMMM"), lower, upper); 
 
  126         } 
else if (Days.daysIn(timeRange).isGreaterThan(Days.THREE)) {
 
  127             timeUnit = DateTimeFieldType.dayOfMonth();
 
  128             long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
 
  129             long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
 
  130             return new RangeDivisionInfo(timeRange, Days.daysIn(timeRange).getDays() + 1, 
TimeUnits.
DAYS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd"), lower, upper); 
 
  131         } 
else if (Hours.hoursIn(timeRange).isGreaterThan(Hours.THREE)) {
 
  132             timeUnit = DateTimeFieldType.hourOfDay();
 
  133             long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
 
  134             long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
 
  135             return new RangeDivisionInfo(timeRange, Hours.hoursIn(timeRange).getHours() + 1, 
TimeUnits.
HOURS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH"), lower, upper); 
 
  136         } 
else if (Minutes.minutesIn(timeRange).isGreaterThan(Minutes.THREE)) {
 
  137             timeUnit = DateTimeFieldType.minuteOfHour();
 
  138             long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
 
  139             long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
 
  140             return new RangeDivisionInfo(timeRange, Minutes.minutesIn(timeRange).getMinutes() + 1, 
TimeUnits.
MINUTES, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH':'mm"), lower, upper); 
 
  142             timeUnit = DateTimeFieldType.secondOfMinute();
 
  143             long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
 
  144             long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
 
  145             return new RangeDivisionInfo(timeRange, Seconds.secondsIn(timeRange).getSeconds() + 1, 
TimeUnits.
SECONDS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH':'mm':'ss"), lower, upper); 
 
  169     @SuppressWarnings(
"ReturnOfCollectionOrArrayField")
 
  171         if (intervals == null) {
 
  172             ArrayList<Interval> tempList = 
new ArrayList<>();
 
  176             DateTime start = range.getStart();
 
  177             while (range.contains(start)) {
 
  180                 final Interval interval = 
new Interval(start, end);
 
  181                 tempList.add(interval);
 
  184             intervals = ImmutableList.copyOf(tempList);
 
  190         return interval.getStart().toString(tickFormatter);
 
String formatForTick(Interval interval)
ImmutableList< Interval > intervals
DateTimeFormatter getTickFormatter()
final DateTimeFormatter tickFormatter
static RangeDivisionInfo getRangeDivisionInfo(Interval timeRange)
final TimeUnits blockSize
static DateTimeZone getJodaTimeZone()
TimeUnits getPeriodSize()
RangeDivisionInfo(Interval timeRange, int periodsInRange, TimeUnits periodSize, DateTimeFormatter tickformatter, long lowerBound, long upperBound)
synchronized List< Interval > getIntervals()