Autopsy  3.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 
23 import org.openide.util.NbBundle;
25 
29 class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearchPanel> {
30 
31  private static final String NONE_SELECTED_MESSAGE = NbBundle
32  .getMessage(KnownStatusSearchFilter.class, "KnownStatusSearchFilter.noneSelectedMsg.text");
33 
34  KnownStatusSearchFilter(KnownStatusSearchPanel panel) {
35  super(panel);
36  }
37 
38  KnownStatusSearchFilter() {
39  this(new KnownStatusSearchPanel());
40  }
41 
42  @Override
43  public boolean isEnabled() {
44  return this.getComponent().getKnownCheckBox().isSelected();
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 = "0";
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 
77  private String predicateHelper(FileKnown knownStatus) {
78  return "known is " + knownStatus.getFileKnownValue(); //NON-NLS
79  }
80 
81  @Override
82  public void addActionListener(ActionListener l) {
83  }
84 }

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