Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
EventStripe.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2015 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.datamodel;
20 
21 import com.google.common.base.Preconditions;
22 import com.google.common.collect.ImmutableSet;
23 import com.google.common.collect.ImmutableSortedSet;
24 import java.util.Comparator;
25 import java.util.Optional;
26 import java.util.SortedSet;
27 import javax.annotation.concurrent.Immutable;
28 import org.python.google.common.base.Objects;
31 
36 @Immutable
37 public final class EventStripe implements EventBundle<EventCluster> {
38 
39  public static EventStripe merge(EventStripe u, EventStripe v) {
40  Preconditions.checkNotNull(u);
41  Preconditions.checkNotNull(v);
42  Preconditions.checkArgument(Objects.equal(u.description, v.description));
43  Preconditions.checkArgument(Objects.equal(u.lod, v.lod));
44  Preconditions.checkArgument(Objects.equal(u.type, v.type));
45  Preconditions.checkArgument(Objects.equal(u.parent, v.parent));
46  return new EventStripe(u, v);
47  }
48 
49  private final EventCluster parent;
50 
51  private final ImmutableSortedSet<EventCluster> clusters;
52 
56  private final EventType type;
57 
61  private final String description;
62 
66  private final DescriptionLoD lod;
67 
71  private final ImmutableSet<Long> eventIDs;
72 
77  private final ImmutableSet<Long> tagged;
78 
82  private final ImmutableSet<Long> hashHits;
83 
85  EventStripe eventStripe = new EventStripe(parent, this.type, this.description, this.lod, clusters, eventIDs, tagged, hashHits);
86  return eventStripe;
87  }
88 
89  private EventStripe(EventCluster parent, EventType type, String description, DescriptionLoD lod, SortedSet<EventCluster> clusters, ImmutableSet<Long> eventIDs, ImmutableSet<Long> tagged, ImmutableSet<Long> hashHits) {
90  this.parent = parent;
91  this.type = type;
92  this.description = description;
93  this.lod = lod;
94  this.clusters = ImmutableSortedSet.copyOf(Comparator.comparing(EventCluster::getStartMillis), clusters);
95 
96  this.eventIDs = eventIDs;
97  this.tagged = tagged;
98  this.hashHits = hashHits;
99  }
100 
101  public EventStripe(EventCluster cluster, EventCluster parent) {
102  this.clusters = ImmutableSortedSet.orderedBy(Comparator.comparing(EventCluster::getStartMillis))
103  .add(cluster).build();
104 
105  type = cluster.getEventType();
106  description = cluster.getDescription();
107  lod = cluster.getDescriptionLoD();
108  eventIDs = cluster.getEventIDs();
109  tagged = cluster.getEventIDsWithTags();
110  hashHits = cluster.getEventIDsWithHashHits();
111  this.parent = parent;
112  }
113 
115  clusters = ImmutableSortedSet.orderedBy(Comparator.comparing(EventCluster::getStartMillis))
116  .addAll(u.getClusters())
117  .addAll(v.getClusters())
118  .build();
119 
120  type = u.getEventType();
121  description = u.getDescription();
122  lod = u.getDescriptionLoD();
123  eventIDs = ImmutableSet.<Long>builder()
124  .addAll(u.getEventIDs())
125  .addAll(v.getEventIDs())
126  .build();
127  tagged = ImmutableSet.<Long>builder()
128  .addAll(u.getEventIDsWithTags())
129  .addAll(v.getEventIDsWithTags())
130  .build();
131  hashHits = ImmutableSet.<Long>builder()
132  .addAll(u.getEventIDsWithHashHits())
133  .addAll(v.getEventIDsWithHashHits())
134  .build();
135  parent = u.getParentBundle().orElse(v.getParentBundle().orElse(null));
136  }
137 
138  @Override
139  public Optional<EventCluster> getParentBundle() {
140  return Optional.ofNullable(parent);
141  }
142 
143  @Override
144  public String getDescription() {
145  return description;
146  }
147 
148  @Override
150  return type;
151  }
152 
153  @Override
155  return lod;
156  }
157 
158  @Override
159  @SuppressWarnings("ReturnOfCollectionOrArrayField")
160  public ImmutableSet<Long> getEventIDs() {
161  return eventIDs;
162  }
163 
164  @Override
165  @SuppressWarnings("ReturnOfCollectionOrArrayField")
166  public ImmutableSet<Long> getEventIDsWithHashHits() {
167  return hashHits;
168  }
169 
170  @Override
171  @SuppressWarnings("ReturnOfCollectionOrArrayField")
172  public ImmutableSet<Long> getEventIDsWithTags() {
173  return tagged;
174  }
175 
176  @Override
177  public long getStartMillis() {
178  return clusters.first().getStartMillis();
179  }
180 
181  @Override
182  public long getEndMillis() {
183  return clusters.last().getEndMillis();
184  }
185 
186  @Override
187  @SuppressWarnings("ReturnOfCollectionOrArrayField")
188  public ImmutableSortedSet< EventCluster> getClusters() {
189  return clusters;
190  }
191 
192  @Override
193  public String toString() {
194  return "EventStripe{" + "description=" + description + ", eventIDs=" + eventIDs.size() + '}'; //NON-NLS
195  }
196 }
EventStripe(EventCluster cluster, EventCluster parent)
EventStripe(EventCluster parent, EventType type, String description, DescriptionLoD lod, SortedSet< EventCluster > clusters, ImmutableSet< Long > eventIDs, ImmutableSet< Long > tagged, ImmutableSet< Long > hashHits)
EventStripe withParent(EventCluster parent)
static EventStripe merge(EventStripe u, EventStripe v)
final ImmutableSortedSet< EventCluster > clusters
ImmutableSortedSet< EventCluster > getClusters()

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.