Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordQueryFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012 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.keywordsearch;
20 
21 import java.util.HashSet;
22 import java.util.Iterator;
23 import java.util.Set;
24 
30 class KeywordQueryFilter {
31 
32  public static enum FilterType {
33 
34  FILE, CHUNK, DATA_SOURCE
35  };
36  private Set<Long> idFilters;
37  private FilterType filterType;
38 
39  public KeywordQueryFilter(FilterType filterType, long id) {
40  this.filterType = filterType;
41  this.idFilters = new HashSet<Long>();
42  this.idFilters.add(id);
43  }
44 
45  public KeywordQueryFilter(FilterType filterType, Set<Long> ids) {
46  this.filterType = filterType;
47  this.idFilters = ids;
48  }
49 
50  public Set<Long> getIdFilters() {
51  return idFilters;
52  }
53 
54  public FilterType getFilterType() {
55  return filterType;
56  }
57 
58  @Override
59  public String toString() {
60  StringBuilder sb = new StringBuilder();
61  String id = null;
62 
63  Iterator<Long> it = idFilters.iterator();
64  for (int i = 0; it.hasNext(); ++i) {
65  if (i > 0) {
66  sb.append(" "); //OR
67  }
68  long idVal = it.next();
69  if (filterType == FilterType.DATA_SOURCE) {
70  id = Server.Schema.IMAGE_ID.toString();
71  } else {
72  id = Server.Schema.ID.toString();
73  }
74  sb.append(id);
75  sb.append(":");
76  sb.append(KeywordSearchUtil.escapeLuceneQuery(Long.toString(idVal)));
77  if (filterType == FilterType.CHUNK) {
78  sb.append("_*");
79  }
80  }
81 
82  return sb.toString();
83  }
84 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.