1 /*
2 * SleuthKit Java Bindings
3 *
4 * Copyright 2017-18 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 java.util.Arrays;
22 import java.util.Collections;
23 import static java.util.Collections.singleton;
24 import java.util.HashMap;
25 import java.util.HashSet;
26 import java.util.Set;
32
38
39 public static final class Type {
40
41 private final String displayName;
42 private final String typeName;
43 private final int typeID;
44
48
49 private final static HashMap<Type, Set<Integer>> typesToArtifactTypeIDs = new HashMap<Type, Set<Integer>>();
50
51 static {
52 typesToArtifactTypeIDs.put(
MESSAGE, hashSetOf(
53 TSK_EMAIL_MSG.getTypeID(),
54 TSK_MESSAGE.getTypeID()));
55 typesToArtifactTypeIDs.put(
CALL_LOG, singleton(
56 TSK_CALLLOG.getTypeID()));
57 typesToArtifactTypeIDs.put(
CONTACT, singleton(
58 TSK_CONTACT.getTypeID()));
59 }
60
61 private static final Set<Type> PREDEFINED_COMMUNICATION_TYPES
62 = Collections.unmodifiableSet(new HashSet<Relationship.Type>(Arrays.asList(
64
72 return PREDEFINED_COMMUNICATION_TYPES;
73 }
74
75 private Type(String name, String displayName,
int id) {
76 this.typeName = name;
77 this.displayName = displayName;
78 this.typeID = id;
79 }
80
87 return displayName;
88 }
89
96 return typeName;
97 }
98
105 return typeID;
106 }
107
108 @Override
110 int hash = 7;
111 hash = 37 * hash + (this.typeName != null ? this.typeName.hashCode() : 0);
112 hash = 37 * hash + this.typeID;
113 return hash;
114 }
115
116 @Override
118 if (this == obj) {
119 return true;
120 }
121 if (obj == null) {
122 return false;
123 }
124 if (getClass() != obj.getClass()) {
125 return false;
126 }
128 if (this.typeID != other.typeID) {
129 return false;
130 }
131 if ((this.typeName == null) ? (other.typeName != null) : !this.typeName.equals(other.typeName)) {
132 return false;
133 }
134 return true;
135 }
136
137 @Override
139 return "{" + this.getClass().getName() + ": typeID=" + typeName + ", displayName=" + this.displayName + ", typeName=" + this.typeName + "}";
140 }
141
153 Set<Integer> get = typesToArtifactTypeIDs.get(this);
155 }
156 }
157 }
boolean equals(Object obj)
static final Relationship.Type CALL_LOG
static final Relationship.Type MESSAGE
static final Relationship.Type CONTACT