Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordHit.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.keywordsearch;
20 
22 import org.sleuthkit.datamodel.BlackboardArtifact;
23 import org.sleuthkit.datamodel.Content;
24 import org.sleuthkit.datamodel.SleuthkitCase;
25 import org.sleuthkit.datamodel.TskCoreException;
26 
33 class KeywordHit {
34 
35  private final String solrDocumentId;
36  private final long solrObjectId;
37  private final int chunkId;
38  private final String snippet;
39  private final Content content;
40  private final BlackboardArtifact artifact;
41 
42  KeywordHit(String solrDocumentId, String snippet) throws TskCoreException {
46  this.solrDocumentId = solrDocumentId;
47 
57  final int separatorIndex = solrDocumentId.indexOf(Server.ID_CHUNK_SEP);
58  if (-1 != separatorIndex) {
59  this.solrObjectId = Long.parseLong(solrDocumentId.substring(0, separatorIndex));
60  this.chunkId = Integer.parseInt(solrDocumentId.substring(separatorIndex + 1));
61  } else {
62  this.solrObjectId = Long.parseLong(solrDocumentId);
63  this.chunkId = 0;
64  }
65 
71  SleuthkitCase caseDb = Case.getCurrentCase().getSleuthkitCase();
72  long fileId;
73  if (this.solrObjectId < 0) {
74  this.artifact = caseDb.getBlackboardArtifact(this.solrObjectId);
75  fileId = artifact.getObjectID();
76  } else {
77  this.artifact = null;
78  fileId = this.solrObjectId;
79  }
80  this.content = caseDb.getContentById(fileId);
81 
85  this.snippet = snippet;
86  }
87 
88  String getSolrDocumentId() {
89  return this.solrDocumentId;
90  }
91 
92  long getSolrObjectId() {
93  return this.solrObjectId;
94  }
95 
96  boolean hasChunkId() {
97  return this.chunkId != 0;
98  }
99 
100  int getChunkId() {
101  return this.chunkId;
102  }
103 
104  boolean hasSnippet() {
105  return !this.snippet.isEmpty();
106  }
107 
108  String getSnippet() {
109  return this.snippet;
110  }
111 
112  Content getContent() {
113  return this.content;
114  }
115 
116  boolean isArtifactHit() {
117  return (null != this.artifact);
118  }
119 
120  BlackboardArtifact getArtifact() {
121  return this.artifact;
122  }
123 
124  @Override
125  public boolean equals(Object obj) {
126  if (null == obj) {
127  return false;
128  }
129  if (getClass() != obj.getClass()) {
130  return false;
131  }
132  final KeywordHit other = (KeywordHit) obj;
133  return (this.solrObjectId == other.solrObjectId && this.chunkId == other.chunkId);
134  }
135 
136  @Override
137  public int hashCode() {
138  int hash = 3;
139  hash = 41 * hash + (int) this.solrObjectId + this.chunkId;
140  return hash;
141  }
142 
143 }

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.