Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AggregateEvent.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.events;
20 
21 import com.google.common.collect.Collections2;
22 import java.util.Collections;
23 import java.util.HashSet;
24 import java.util.List;
25 import java.util.Set;
26 import javax.annotation.concurrent.Immutable;
27 import org.joda.time.Interval;
28 import org.openide.util.NbBundle;
32 
37 @Immutable
38 public class AggregateEvent {
39 
40  final private Interval span;
41 
42  final private EventType type;
43 
44  final private Set<Long> eventIDs;
45 
46  final private String description;
47 
48  private final DescriptionLOD lod;
49 
50  public AggregateEvent(Interval spanningInterval, EventType type, Set<Long> eventIDs, String description, DescriptionLOD lod) {
51 
52  this.span = spanningInterval;
53  this.type = type;
54  this.description = description;
55 
56  this.eventIDs = eventIDs;
57  this.lod = lod;
58  }
59 
60  public AggregateEvent(Interval spanningInterval, EventType type, List<String> events, String description, DescriptionLOD lod) {
61 
62  this.span = spanningInterval;
63  this.type = type;
64  this.description = description;
65 
66  this.eventIDs = new HashSet<>(Collections2.transform(events, Long::valueOf));
67  this.lod = lod;
68  }
69 
71  public Interval getSpan() {
72  return span;
73  }
74 
75  public Set<Long> getEventIDs() {
76  return Collections.unmodifiableSet(eventIDs);
77  }
78 
79  public String getDescription() {
80  return description;
81  }
82 
83  public EventType getType() {
84  return type;
85  }
86 
96 
97  if (ag1.getType() != ag2.getType()) {
98  throw new IllegalArgumentException("aggregate events are not compatible they have different types");
99  }
100 
101  if (!ag1.getDescription().equals(ag2.getDescription())) {
102  throw new IllegalArgumentException("aggregate events are not compatible they have different descriptions");
103  }
104  HashSet<Long> ids = new HashSet<>(ag1.getEventIDs());
105  ids.addAll(ag2.getEventIDs());
106 
107  //TODO: check that types/descriptions are actually the same -jm
108  return new AggregateEvent(IntervalUtils.span(ag1.span, ag2.span), ag1.getType(), ids, ag1.getDescription(), ag1.lod);
109  }
110 
112  return lod;
113  }
114 }
static AggregateEvent merge(AggregateEvent ag1, AggregateEvent ag2)
AggregateEvent(Interval spanningInterval, EventType type, Set< Long > eventIDs, String description, DescriptionLOD lod)
AggregateEvent(Interval spanningInterval, EventType type, List< String > events, String description, DescriptionLOD lod)
static Interval span(Interval range, final Interval range2)

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.