Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
IntersectionFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-15 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.timeline.filters;
20 
21 import java.util.List;
22 import java.util.stream.Collectors;
23 import javafx.collections.FXCollections;
24 import org.openide.util.NbBundle;
25 
29 public class IntersectionFilter<S extends Filter> extends CompoundFilter<S> {
30 
31  public IntersectionFilter(List<S> subFilters) {
32  super(subFilters);
33  }
34 
35  public IntersectionFilter() {
36  super(FXCollections.<S>observableArrayList());
37  }
38 
39  @Override
41  @SuppressWarnings("unchecked")
43  (List<S>) this.getSubFilters().stream()
44  .map(Filter::copyOf)
45  .collect(Collectors.toList()));
46  filter.setSelected(isSelected());
47  filter.setDisabled(isDisabled());
48  return filter;
49  }
50 
51  @Override
52  @NbBundle.Messages({"# {0} - sub filter displaynames",
53  "IntersectionFilter.displayName.text=Intersection{0}"})
54  public String getDisplayName() {
55  String collect = getSubFilters().stream()
57  .collect(Collectors.joining(",", "[", "]"));
58  return Bundle.IntersectionFilter_displayName_text(collect);
59  }
60 
61  @Override
62  public String getHTMLReportString() {
63  return getSubFilters().stream()
64  .filter(Filter::isSelected)
66  .collect(Collectors.joining("</li><li>", "<ul><li>", "</li></ul>")); // NON-NLS
67  }
68 
69  @Override
70  public boolean equals(Object obj) {
71  if (obj == null) {
72  return false;
73  }
74  if (getClass() != obj.getClass()) {
75  return false;
76  }
77  @SuppressWarnings("unchecked")
78  final IntersectionFilter<S> other = (IntersectionFilter<S>) obj;
79 
80  if (isSelected() != other.isSelected()) {
81  return false;
82  }
83 
84  for (int i = 0; i < getSubFilters().size(); i++) {
85  if (getSubFilters().get(i).equals(other.getSubFilters().get(i)) == false) {
86  return false;
87  }
88  }
89  return true;
90  }
91 }
final ObservableList< SubFilterType > getSubFilters()

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.