Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
Keyword.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2011-2018 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 */
19package org.sleuthkit.autopsy.keywordsearch;
20
21import java.text.Normalizer;
22import org.openide.util.NbBundle;
23import org.sleuthkit.datamodel.BlackboardAttribute;
24
34public class Keyword {
35
36 private String searchTerm;
37 private boolean isLiteral;
38 private boolean isWholeWord;
39 private BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType;
40 private final String listName;
41 /*
42 * For substring searches, original search term (e.g. "pass" or "enger") can
43 * be different from the search term (e.g. "passenger") that is found and
44 * used (e.g. for highlighting purposes).
45 */
46 private final String originalTerm;
47
60 Keyword(String searchTerm, boolean isLiteral, boolean isWholeWord) {
62 }
63
92 Keyword(String searchTerm, boolean isLiteral, boolean isWholeWord, String listName, String originalTerm) {
93 this.searchTerm = Normalizer.normalize(searchTerm, Normalizer.Form.NFKC);
94 this.isLiteral = isLiteral;
95 this.isWholeWord = isWholeWord;
96 this.listName = listName;
97 this.originalTerm = originalTerm;
98
99 }
100
115 Keyword(String searchTerm, boolean isLiteral, BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType) {
116 this(searchTerm, isLiteral, true);
117 this.artifactAtrributeType = artifactAtrributeType;
118 }
119
126 public String getSearchTerm() {
127 return searchTerm;
128 }
129
136 public boolean searchTermIsLiteral() {
137 return isLiteral;
138 }
139
147 public boolean searchTermIsWholeWord() {
148 return isWholeWord;
149 }
150
151 String getSearchTermType() {
152 if (isLiteral) {
153 if (isWholeWord) {
154 return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.exactButton.text");
155 } else {
156 return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.substringButton.text");
157 }
158 } else {
159 return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.regexButton.text");
160 }
161 }
162
172 void setArtifactAttributeType(BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType) {
173 this.artifactAtrributeType = artifactAtrributeType;
174 }
175
185 BlackboardAttribute.ATTRIBUTE_TYPE getArtifactAttributeType() {
186 return this.artifactAtrributeType;
187 }
188
189 @Override
190 public String toString() {
191 return String.format("Keyword{searchTerm='%s', isLiteral=%s, isWholeWord=%s}", searchTerm, isLiteral, isWholeWord);
192 }
193
194 @Override
195 public boolean equals(Object obj) {
196 if (obj == null) {
197 return false;
198 }
199 if (getClass() != obj.getClass()) {
200 return false;
201 }
202 Keyword other = (Keyword) obj;
203 return (this.searchTerm.equals(other.getSearchTerm())
204 && this.isLiteral == other.searchTermIsLiteral()
205 && this.isWholeWord == other.searchTermIsWholeWord()
206 && this.listName.equals(other.getListName())
207 && this.originalTerm.equals(other.getOriginalTerm()));
208 }
209
210 @Override
211 public int hashCode() {
212 int hash = 7;
213 hash = 17 * hash + this.searchTerm.hashCode();
214 hash = 17 * hash + this.listName.hashCode();
215 hash = 17 * hash + (this.isLiteral ? 1 : 0);
216 hash = 17 * hash + (this.isWholeWord ? 1 : 0);
217 hash = 17 * hash + this.originalTerm.hashCode();
218 return hash;
219 }
220
224 String getListName() {
225 return listName;
226 }
227
231 String getOriginalTerm() {
232 return originalTerm;
233 }
234
235}
BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType
Definition Keyword.java:39

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.