Autopsy  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 
49  Keyword(String searchTerm, boolean isLiteral) {
50  this.searchTerm = searchTerm;
51  this.isLiteral = isLiteral;
52  this.isWholeWord = true;
53  }
54 
67  Keyword(String searchTerm, boolean isLiteral, boolean isWholeWord) {
68  this.searchTerm = searchTerm;
69  this.isLiteral = isLiteral;
70  this.isWholeWord = isWholeWord;
71  }
72 
87  Keyword(String searchTerm, boolean isLiteral, BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType) {
88  this(searchTerm, isLiteral);
89  this.artifactAtrributeType = artifactAtrributeType;
90  }
91 
98  String getSearchTerm() {
99  return searchTerm;
100  }
101 
108  boolean searchTermIsLiteral() {
109  return isLiteral;
110  }
111 
119  boolean searchTermIsWholeWord() {
120  return isWholeWord;
121  }
122 
123  String getSearchTermType() {
124  if (isLiteral) {
125  if (isWholeWord) {
126  return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.exactButton.text");
127  } else {
128  return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.substringButton.text");
129  }
130  } else {
131  return NbBundle.getMessage(NewKeywordPanel.class, "NewKeywordPanel.regexButton.text");
132  }
133  }
134 
144  void setArtifactAttributeType(BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType) {
145  this.artifactAtrributeType = artifactAtrributeType;
146  }
147 
157  BlackboardAttribute.ATTRIBUTE_TYPE getArtifactAttributeType() {
158  return this.artifactAtrributeType;
159  }
160 
161  @Override
162  public String toString() {
163  return String.format("Keyword{searchTerm='%s', isLiteral=%s, isWholeWord=%s}", searchTerm, isLiteral, isWholeWord);
164  }
165 
166  @Override
167  public boolean equals(Object obj) {
168  if (obj == null) {
169  return false;
170  }
171  if (getClass() != obj.getClass()) {
172  return false;
173  }
174  Keyword other = (Keyword) obj;
175  return (this.searchTerm.equals(other.getSearchTerm())
176  && this.isLiteral == other.searchTermIsLiteral()
177  && this.isWholeWord == other.searchTermIsWholeWord());
178  }
179 
180  @Override
181  public int hashCode() {
182  int hash = 7;
183  hash = 17 * hash + this.searchTerm.hashCode();
184  hash = 17 * hash + (this.isLiteral ? 1 : 0);
185  hash = 17 * hash + (this.isWholeWord ? 1 : 0);
186  return hash;
187  }
188 
189 }

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