Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
KnownStatusSearchFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 - 2013 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.filesearch;
20 
21 import java.awt.event.ActionListener;
22 import org.openide.util.NbBundle;
23 import org.sleuthkit.datamodel.TskData.FileKnown;
24 
28 class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearchPanel> {
29 
30  private static final String NONE_SELECTED_MESSAGE = NbBundle
31  .getMessage(KnownStatusSearchFilter.class, "KnownStatusSearchFilter.noneSelectedMsg.text");
32 
33  KnownStatusSearchFilter(KnownStatusSearchPanel panel) {
34  super(panel);
35  }
36 
37  KnownStatusSearchFilter() {
38  this(new KnownStatusSearchPanel());
39  }
40 
41  @Override
42  public boolean isEnabled() {
43  return this.getComponent().getKnownCheckBox().isSelected();
44 
45  }
46 
47  @Override
48  public String getPredicate() throws FilterValidationException {
49  KnownStatusSearchPanel panel = this.getComponent();
50 
51  boolean unknown = panel.getUnknownOptionCheckBox().isSelected();
52  boolean known = panel.getKnownOptionCheckBox().isSelected();
53  boolean knownBad = panel.getKnownBadOptionCheckBox().isSelected();
54 
55  if (!(unknown || known || knownBad)) {
56  throw new FilterValidationException(NONE_SELECTED_MESSAGE);
57  }
58 
59  String expr = "NULL";
60  if (unknown) {
61  expr += " OR " + predicateHelper(FileKnown.UNKNOWN); //NON-NLS
62  }
63  if (known) {
64  expr += " OR " + predicateHelper(FileKnown.KNOWN); //NON-NLS
65  }
66  if (knownBad) {
67  expr += " OR " + predicateHelper(FileKnown.BAD); //NON-NLS
68  }
69  return expr;
70  }
71 
79  private String predicateHelper(FileKnown knownStatus) {
80  return "known = " + knownStatus.getFileKnownValue(); //NON-NLS
81  }
82 
83  @Override
84  public void addActionListener(ActionListener l) {
85  }
86 
87  @Override
88  public boolean isValid() {
89  return this.getComponent().isValidSearch();
90  }
91 }

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