Autopsy  4.4.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-2016 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 org.openide.util.NbBundle;
22 import org.sleuthkit.datamodel.BlackboardAttribute;
23 
33 class Keyword {
34 
35  private String searchTerm;
36  private boolean isLiteral;
37  private boolean isWholeWord;
38  private BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType;
39  private final String listName;
40  /*
41  * For substring searches, original search term (e.g. "pass" or "enger") can
42  * be different from the search term (e.g. "passenger") that is found and
43  * used (e.g. for highlighting purposes).
44  */
45  private final String originalTerm;
46 
59  Keyword(String searchTerm, boolean isLiteral, boolean isWholeWord) {
60  this.searchTerm = searchTerm;
61  this.isLiteral = isLiteral;
62  this.isWholeWord = isWholeWord;
63  this.listName = "";
64  this.originalTerm = searchTerm;
65  }
66 
95  Keyword(String searchTerm, boolean isLiteral, boolean isWholeWord, String listName, String originalTerm) {
96  this.searchTerm = searchTerm;
97  this.isLiteral = isLiteral;
98  this.isWholeWord = isWholeWord;
99  this.listName = listName;
100  this.originalTerm = originalTerm;
101  }
102 
117  Keyword(String searchTerm, boolean isLiteral, BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType) {
118  this(searchTerm, isLiteral, true);
119  this.artifactAtrributeType = artifactAtrributeType;
120  }
121 
128  String getSearchTerm() {
129  return searchTerm;
130  }
131 
138  boolean searchTermIsLiteral() {
139  return isLiteral;
140  }
141 
149  boolean searchTermIsWholeWord() {
150  return isWholeWord;
151  }
152 
153  String getSearchTermType() {
154  if (isLiteral) {
155  if (isWholeWord) {
156  return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.exactButton.text");
157  } else {
158  return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.substringButton.text");
159  }
160  } else {
161  return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.regexButton.text");
162  }
163  }
164 
174  void setArtifactAttributeType(BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType) {
175  this.artifactAtrributeType = artifactAtrributeType;
176  }
177 
187  BlackboardAttribute.ATTRIBUTE_TYPE getArtifactAttributeType() {
188  return this.artifactAtrributeType;
189  }
190 
191  @Override
192  public String toString() {
193  return String.format("Keyword{searchTerm='%s', isLiteral=%s, isWholeWord=%s}", searchTerm, isLiteral, isWholeWord);
194  }
195 
196  @Override
197  public boolean equals(Object obj) {
198  if (obj == null) {
199  return false;
200  }
201  if (getClass() != obj.getClass()) {
202  return false;
203  }
204  Keyword other = (Keyword) obj;
205  return (this.searchTerm.equals(other.getSearchTerm())
206  && this.isLiteral == other.searchTermIsLiteral()
207  && this.isWholeWord == other.searchTermIsWholeWord()
208  && this.listName.equals(other.getListName())
209  && this.originalTerm.equals(other.getOriginalTerm()));
210  }
211 
212  @Override
213  public int hashCode() {
214  int hash = 7;
215  hash = 17 * hash + this.searchTerm.hashCode();
216  hash = 17 * hash + (this.isLiteral ? 1 : 0);
217  hash = 17 * hash + (this.isWholeWord ? 1 : 0);
218  return hash;
219  }
220 
224  String getListName() {
225  return listName;
226  }
227 
231  String getOriginalTerm() {
232  return originalTerm;
233  }
234 
235 }

Copyright © 2012-2016 Basis Technology. Generated on: Fri Sep 29 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.