Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
MimeTypeFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.Messages;
23 
27 class MimeTypeFilter extends AbstractFileSearchFilter<MimeTypePanel> {
28 
29  MimeTypeFilter(MimeTypePanel component) {
30  super(component);
31  }
32 
33  MimeTypeFilter() {
34  this(new MimeTypePanel());
35  }
36 
37  @Override
38  public boolean isEnabled() {
39  return this.getComponent().isSelected();
40  }
41 
42  @Override
43  public String getPredicate() throws FilterValidationException {
44  String predicate = "";
45  for (String mimeType : this.getComponent().getMimeTypesSelected()) {
46  predicate += "mime_type = '" + mimeType + "' OR ";
47  }
48  if (predicate.length() > 3) {
49  predicate = predicate.substring(0, predicate.length() - 3);
50  }
51  return predicate;
52  }
53 
54  @Override
55  public void addActionListener(ActionListener l) {
56  }
57 
58  @Override
59  @Messages({
60  "MimeTypeFilter.errorMessage.emptyMimeType=At least one MIME type must be selected."
61  })
62  public boolean isValid() {
63  if (this.getComponent().getMimeTypesSelected().isEmpty()) {
64  setLastError(Bundle.MimeTypeFilter_errorMessage_emptyMimeType());
65  return false;
66  }
67  return true;
68  }
69 
73  void resetMimeTypeFilter() {
74  this.getComponent().resetMimeTypePanel();
75  }
76 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.