Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MimeTypeFilter.java
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 package org.sleuthkit.autopsy.filesearch;
7 
8 import java.awt.event.ActionListener;
9 import org.openide.util.NbBundle.Messages;
10 
14 class MimeTypeFilter extends AbstractFileSearchFilter<MimeTypePanel> {
15 
16  public MimeTypeFilter(MimeTypePanel component) {
17  super(component);
18  }
19 
20  public MimeTypeFilter() {
21  this(new MimeTypePanel());
22  }
23 
24  @Override
25  public boolean isEnabled() {
26  return this.getComponent().isSelected();
27  }
28 
29  @Override
30  public String getPredicate() throws FilterValidationException {
31  String predicate = "";
32  for (String mimeType : this.getComponent().getMimeTypesSelected()) {
33  predicate += "mime_type = '" + mimeType + "' OR ";
34  }
35  if (predicate.length() > 3) {
36  predicate = predicate.substring(0, predicate.length() - 3);
37  }
38  return predicate;
39  }
40 
41  @Override
42  public void addActionListener(ActionListener l) {
43  }
44 
45  @Override
46  @Messages ({
47  "MimeTypeFilter.errorMessage.emptyMimeType=At least one MIME type must be selected."
48  })
49  public boolean isValid() {
50  if(this.getComponent().getMimeTypesSelected().isEmpty()){
51  setLastError(Bundle.MimeTypeFilter_errorMessage_emptyMimeType());
52  return false;
53  }
54  return true;
55  }
56 }

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.