Autopsy  4.9.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  */
19 package org.sleuthkit.autopsy.keywordsearch;
20 
21 import java.text.Normalizer;
22 import org.openide.util.NbBundle;
23 import org.sleuthkit.datamodel.BlackboardAttribute;
24 
34 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) {
61  this(searchTerm, isLiteral, isWholeWord, "", searchTerm);
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  String getSearchTerm() {
127  return searchTerm;
128  }
129 
136  boolean searchTermIsLiteral() {
137  return isLiteral;
138  }
139 
147  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.isLiteral ? 1 : 0);
215  hash = 17 * hash + (this.isWholeWord ? 1 : 0);
216  return hash;
217  }
218 
222  String getListName() {
223  return listName;
224  }
225 
229  String getOriginalTerm() {
230  return originalTerm;
231  }
232 
233 }

Copyright © 2012-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.