Sleuth Kit Java Bindings (JNI)  4.6
Java bindings for using The Sleuth Kit
TimelineEventTypeImpl.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
3  *
4  * Copyright 2018-2019 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.datamodel;
20 
21 import com.google.common.collect.ImmutableSortedSet;
22 import java.util.Optional;
23 import java.util.SortedSet;
24 import org.apache.commons.lang3.ObjectUtils;
25 
29 class TimelineEventTypeImpl implements TimelineEventType {
30 
31  private final long typeID;
32  private final String displayName;
33  private final TimelineEventType superType;
34  private final TimelineEventType.HierarchyLevel eventTypeZoomLevel;
35 
43  TimelineEventTypeImpl(long typeID, String displayName, TimelineEventType.HierarchyLevel eventTypeZoomLevel, TimelineEventType superType) {
44  this.superType = superType;
45  this.typeID = typeID;
46  this.displayName = displayName;
47  this.eventTypeZoomLevel = eventTypeZoomLevel;
48  }
49 
50  TimelineEventDescription parseDescription(String fullDescriptionRaw, String medDescriptionRaw, String shortDescriptionRaw) {
51  // The standard/default implementation: Just bundle the three description levels into one object.
52  return new TimelineEventDescription(fullDescriptionRaw, medDescriptionRaw, shortDescriptionRaw);
53  }
54 
55  @Override
56  public SortedSet<? extends TimelineEventType> getChildren() {
57  return ImmutableSortedSet.of();
58  }
59 
60  @Override
61  public Optional<? extends TimelineEventType> getChild(String string) {
62  return getChildren().stream()
63  .filter(type -> type.getDisplayName().equalsIgnoreCase(displayName))
64  .findFirst();
65  }
66 
67  @Override
68  public String getDisplayName() {
69  return displayName;
70  }
71 
72  @Override
73  public TimelineEventType getParent() {
74  return ObjectUtils.defaultIfNull(superType, ROOT_EVENT_TYPE);
75 
76  }
77 
78  @Override
79  public TimelineEventType.HierarchyLevel getTypeHierarchyLevel() {
80  return eventTypeZoomLevel;
81  }
82 
83  @Override
84  public long getTypeID() {
85  return typeID;
86  }
87 
88  @Override
89  public int hashCode() {
90  int hash = 5;
91  hash = 17 * hash + (int) (this.typeID ^ (this.typeID >>> 32));
92  return hash;
93  }
94 
95  @Override
96  public boolean equals(Object obj) {
97  if (this == obj) {
98  return true;
99  }
100  if (obj == null) {
101  return false;
102  }
103  if (getClass() != obj.getClass()) {
104  return false;
105  }
106  final TimelineEventType other = (TimelineEventType) obj;
107  return this.getTypeID() == other.getTypeID();
108  }
109 
110  @Override
111  public String toString() {
112  return "StandardEventType{" + "id=" + getTypeID() + ", displayName=" + getDisplayName() + '}';
113  }
114 }

Copyright © 2011-2018 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.