Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
TypeFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-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.Objects;
22 import java.util.stream.Collectors;
23 import javafx.collections.FXCollections;
24 import javafx.scene.image.Image;
25 import javafx.scene.paint.Color;
26 import org.openide.util.NbBundle;
29 
34 public class TypeFilter extends UnionFilter<TypeFilter> {
35 
39  private final EventType eventType;
40 
49  private TypeFilter(EventType et, boolean recursive) {
50  super(FXCollections.observableArrayList());
51  this.eventType = et;
52 
53  if (recursive) { // add subfilters for each subtype
54  for (EventType subType : et.getSubTypes()) {
55  this.getSubFilters().add(new TypeFilter(subType));
56  }
57  }
58  }
59 
66  public TypeFilter(EventType et) {
67  this(et, true);
68  }
69 
71  return eventType;
72  }
73 
74  @Override
75  @NbBundle.Messages("TypeFilter.displayName.text=Event Type")
76  public String getDisplayName() {
77  return (eventType == RootEventType.getInstance())
78  ? Bundle.TypeFilter_displayName_text()
79  : eventType.getDisplayName();
80  }
81 
85  public Color getColor() {
86  return eventType.getColor();
87  }
88 
92  public Image getFXImage() {
93  return eventType.getFXImage();
94  }
95 
96  @Override
97  public TypeFilter copyOf() {
98  //make a nonrecursive copy of this filter
99  final TypeFilter typeFilter = new TypeFilter(eventType, false);
100  typeFilter.setSelected(isSelected());
101  typeFilter.setDisabled(isDisabled());
102  //add a copy of each subfilter
103  this.getSubFilters().forEach((TypeFilter t) -> {
104  typeFilter.getSubFilters().add(t.copyOf());
105  });
106 
107  return typeFilter;
108  }
109 
110  @Override
111  public String getHTMLReportString() {
112  String string = getEventType().getDisplayName() + getStringCheckBox();
113  if (getSubFilters().isEmpty() == false) {
114  string = string + " : " + getSubFilters().stream().filter(Filter::isSelected).map(Filter::getHTMLReportString).collect(Collectors.joining("</li><li>", "<ul><li>", "</li></ul>")); // NON-NLS
115  }
116  return string;
117  }
118 
119  @Override
120  public boolean equals(Object obj) {
121  if (obj == null) {
122  return false;
123  }
124  if (getClass() != obj.getClass()) {
125  return false;
126  }
127  final TypeFilter other = (TypeFilter) obj;
128 
129  if (isSelected() != other.isSelected()) {
130  return false;
131  }
132 
133  if (this.eventType != other.eventType) {
134  return false;
135  }
136  return areSubFiltersEqual(this, other);
137  }
138 
139  @Override
140  public int hashCode() {
141  int hash = 7;
142  hash = 67 * hash + Objects.hashCode(this.eventType);
143  return hash;
144  }
145 }
TypeFilter(EventType et, boolean recursive)
Definition: TypeFilter.java:49

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.