Sleuth Kit Java Bindings (JNI)  4.5.0
Java bindings for using The Sleuth Kit
Relationship.java
Go to the documentation of this file.
1 /*
2  * SleuthKit Java Bindings
3  *
4  * Copyright 2017 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;
31 import static org.sleuthkit.datamodel.CollectionUtils.hashSetOf;
32 
37 public class Relationship {
38 
39  public static final class Type {
40 
41  private final String displayName;
42  private final String typeName;
43  private final int typeID;
44 
45  public static final Relationship.Type MESSAGE = new Type("MESSAGE", "Message", 1);
46  public static final Relationship.Type CALL_LOG = new Type("CALL_LOG", "Call Log", 2);
47  public static final Relationship.Type CONTACT = new Type("CONTACT", "Contact", 3);
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(
63  MESSAGE, CALL_LOG)));
64 
71  static Set<Relationship.Type> getPredefinedCommunicationTypes() {
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 
81  public String getDisplayName() {
82  return displayName;
83  }
84 
85  public String getTypeName() {
86  return typeName;
87  }
88 
89  public int getTypeID() {
90  return typeID;
91  }
92 
93  @Override
94  public int hashCode() {
95  int hash = 7;
96  hash = 37 * hash + (this.typeName != null ? this.typeName.hashCode() : 0);
97  hash = 37 * hash + this.typeID;
98  return hash;
99  }
100 
101  @Override
102  public boolean equals(Object obj) {
103  if (this == obj) {
104  return true;
105  }
106  if (obj == null) {
107  return false;
108  }
109  if (getClass() != obj.getClass()) {
110  return false;
111  }
112  final Type other = (Type) obj;
113  if (this.typeID != other.typeID) {
114  return false;
115  }
116  if ((this.typeName == null) ? (other.typeName != null) : !this.typeName.equals(other.typeName)) {
117  return false;
118  }
119  return true;
120  }
121 
122  @Override
123  public String toString() {
124  return "{" + this.getClass().getName() + ": typeID=" + typeName + " displayName=" + this.displayName + ", typeName=" + this.typeName + "}";
125  }
126 
137  boolean isCreatableFrom(BlackboardArtifact relationshipArtifact) {
138  Set<Integer> get = typesToArtifactTypeIDs.get(this);
139  return get != null && get.contains(relationshipArtifact.getArtifactTypeID());
140  }
141  }
142 }
static final Set< Type > PREDEFINED_COMMUNICATION_TYPES
static final Relationship.Type CALL_LOG
Type(String name, String displayName, int id)
static final Relationship.Type MESSAGE
static final Relationship.Type CONTACT
static final HashMap< Type, Set< Integer > > typesToArtifactTypeIDs

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