Autopsy  3.1
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 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 
32 public class TypeFilter extends UnionFilter {
33 
35  private final EventType eventType;
36 
43  private TypeFilter(EventType et, boolean recursive) {
44  super(FXCollections.observableArrayList());
45  this.eventType = et;
46 
47  if (recursive) { // add subfilters for each subtype
48  for (EventType subType : et.getSubTypes()) {
49  this.getSubFilters().add(new TypeFilter(subType));
50  }
51  }
52  }
53 
58  public TypeFilter(EventType et) {
59  this(et, true);
60  }
61 
63  return eventType;
64  }
65 
66  @Override
67  public String getDisplayName() {
68  if (eventType == RootEventType.getInstance()) {
69  return NbBundle.getMessage(this.getClass(), "TypeFilter.displayName.text");
70  } else {
71  return eventType.getDisplayName();
72  }
73  }
74 
76  public Color getColor() {
77  return eventType.getColor();
78  }
79 
81  public Image getFXImage() {
82  return eventType.getFXImage();
83  }
84 
85  @Override
86  public TypeFilter copyOf() {
87  //make a nonrecursive copy of this filter
88  final TypeFilter typeFilter = new TypeFilter(eventType, false);
89  typeFilter.setActive(isActive());
90  typeFilter.setDisabled(isDisabled());
91  //add a copy of each subfilter
92  this.getSubFilters().forEach((Filter t) -> {
93  typeFilter.getSubFilters().add(t.copyOf());
94  });
95 
96  return typeFilter;
97  }
98 
99  @Override
100  public String getHTMLReportString() {
101  String string = getEventType().getDisplayName() + getStringCheckBox();
102  if (getSubFilters().isEmpty() == false) {
103  string = string + " : " + getSubFilters().stream().filter(Filter::isActive).map(Filter::getHTMLReportString).collect(Collectors.joining("</li><li>", "<ul><li>", "</li></ul>")); // NON-NLS
104  }
105  return string;
106  }
107 
108  @Override
109  public boolean equals(Object obj) {
110  if (obj == null) {
111  return false;
112  }
113  if (getClass() != obj.getClass()) {
114  return false;
115  }
116  final TypeFilter other = (TypeFilter) obj;
117 
118  if (isActive() != other.isActive()) {
119  return false;
120  }
121 
122  if (this.eventType != other.eventType) {
123  return false;
124  }
125 
126  for (int i = 0; i < getSubFilters().size(); i++) {
127  if (getSubFilters().get(i).equals(other.getSubFilters().get(i)) == false) {
128  return false;
129  }
130  }
131  return true;
132  }
133 
134  @Override
135  public int hashCode() {
136  int hash = 7;
137  hash = 67 * hash + Objects.hashCode(this.eventType);
138  return hash;
139  }
140 
141 }
TypeFilter(EventType et, boolean recursive)
Definition: TypeFilter.java:43

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.