19 package org.sleuthkit.autopsy.filequery;
21 import com.google.common.collect.ImmutableSet;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.List;
27 import org.openide.util.NbBundle;
33 final class FileSearchData {
35 private final static long BYTES_PER_MB = 1000000;
41 "FileSearchData.Frequency.unique.displayName=Unique (1)",
42 "FileSearchData.Frequency.rare.displayName=Rare (2-10)",
43 "FileSearchData.Frequency.common.displayName=Common (11 - 100)",
44 "FileSearchData.Frequency.verycommon.displayName=Very Common (100+)",
45 "FileSearchData.Frequency.known.displayName=Known (NSRL)",
46 "FileSearchData.Frequency.unknown.displayName=Unknown",})
48 UNIQUE(0, 1, Bundle.FileSearchData_Frequency_unique_displayName()),
49 RARE(1, 10, Bundle.FileSearchData_Frequency_rare_displayName()),
50 COMMON(2, 100, Bundle.FileSearchData_Frequency_common_displayName()),
51 VERY_COMMON(3, 0, Bundle.FileSearchData_Frequency_verycommon_displayName()),
52 KNOWN(4, 0, Bundle.FileSearchData_Frequency_known_displayName()),
53 UNKNOWN(5, 0, Bundle.FileSearchData_Frequency_unknown_displayName());
55 private final int ranking;
56 private final String displayName;
57 private final int maxOccur;
59 Frequency(
int ranking,
int maxOccur, String displayName) {
60 this.ranking = ranking;
61 this.maxOccur = maxOccur;
62 this.displayName = displayName;
81 static Frequency fromCount(
long count) {
82 if (count <= UNIQUE.getMaxOccur()) {
84 }
else if (count <= RARE.getMaxOccur()) {
86 }
else if (count <= COMMON.getMaxOccur()) {
98 static List<Frequency> getOptionsForFilteringWithCr() {
99 return Arrays.asList(UNIQUE, RARE, COMMON, VERY_COMMON, KNOWN);
108 static List<Frequency> getOptionsForFilteringWithoutCr() {
109 return Arrays.asList(KNOWN, UNKNOWN);
113 public String toString() {
129 "FileSearchData.FileSize.XXLARGE_IMAGE.displayName=XXLarge: 200MB+",
130 "FileSearchData.FileSize.XLARGE_IMAGE.displayName=XLarge: 50-200MB",
131 "FileSearchData.FileSize.LARGE_IMAGE.displayName=Large: 1-50MB",
132 "FileSearchData.FileSize.MEDIUM_IMAGE.displayName=Medium: 100KB-1MB",
133 "FileSearchData.FileSize.SMALL_IMAGE.displayName=Small: 16-100KB",
134 "FileSearchData.FileSize.XSMALL_IMAGE.displayName=XSmall: 0-16KB",
135 "FileSearchData.FileSize.XXLARGE_VIDEO.displayName=XXLarge: 10GB+",
136 "FileSearchData.FileSize.XLARGE_VIDEO.displayName=XLarge: 5-10GB",
137 "FileSearchData.FileSize.LARGE_VIDEO.displayName=Large: 1-5GB",
138 "FileSearchData.FileSize.MEDIUM_VIDEO.displayName=Medium: 100MB-1GB",
139 "FileSearchData.FileSize.SMALL_VIDEO.displayName=Small: 500KB-100MB",
140 "FileSearchData.FileSize.XSMALL_VIDEO.displayName=XSmall: 0-500KB",})
142 XXLARGE_VIDEO(0, 10000 * BYTES_PER_MB, -1, Bundle.FileSearchData_FileSize_XXLARGE_VIDEO_displayName()),
143 XLARGE_VIDEO(1, 5000 * BYTES_PER_MB, 10000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_XLARGE_VIDEO_displayName()),
144 LARGE_VIDEO(2, 1000 * BYTES_PER_MB, 5000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_LARGE_VIDEO_displayName()),
145 MEDIUM_VIDEO(3, 100 * BYTES_PER_MB, 1000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_MEDIUM_VIDEO_displayName()),
146 SMALL_VIDEO(4, 500000, 100 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_SMALL_VIDEO_displayName()),
147 XSMALL_VIDEO(5, 0, 500000, Bundle.FileSearchData_FileSize_XSMALL_VIDEO_displayName()),
148 XXLARGE_IMAGE(6, 200 * BYTES_PER_MB, -1, Bundle.FileSearchData_FileSize_XXLARGE_IMAGE_displayName()),
149 XLARGE_IMAGE(7, 50 * BYTES_PER_MB, 200 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_XLARGE_IMAGE_displayName()),
150 LARGE_IMAGE(8, 1 * BYTES_PER_MB, 50 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_LARGE_IMAGE_displayName()),
151 MEDIUM_IMAGE(9, 100000, 1 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_MEDIUM_IMAGE_displayName()),
152 SMALL_IMAGE(10, 16000, 100000, Bundle.FileSearchData_FileSize_SMALL_IMAGE_displayName()),
153 XSMALL_IMAGE(11, 0, 16000, Bundle.FileSearchData_FileSize_XSMALL_IMAGE_displayName());
155 private final int ranking;
156 private final long minBytes;
157 private final long maxBytes;
158 private final String displayName;
159 final static long NO_MAXIMUM = -1;
161 FileSize(
int ranking,
long minB,
long maxB, String displayName) {
162 this.ranking = ranking;
163 this.minBytes = minB;
165 this.maxBytes = maxB;
167 this.maxBytes = NO_MAXIMUM;
169 this.displayName = displayName;
180 static FileSize fromImageSize(
long size) {
181 if (size > XXLARGE_IMAGE.getMinBytes()) {
182 return XXLARGE_IMAGE;
183 }
else if (size > XLARGE_IMAGE.getMinBytes()) {
185 }
else if (size > LARGE_IMAGE.getMinBytes()) {
187 }
else if (size > MEDIUM_IMAGE.getMinBytes()) {
189 }
else if (size > SMALL_IMAGE.getMinBytes()) {
204 static FileSize fromVideoSize(
long size) {
205 if (size > XXLARGE_VIDEO.getMinBytes()) {
206 return XXLARGE_VIDEO;
207 }
else if (size > XLARGE_VIDEO.getMinBytes()) {
209 }
else if (size > LARGE_VIDEO.getMinBytes()) {
211 }
else if (size > MEDIUM_VIDEO.getMinBytes()) {
213 }
else if (size > SMALL_VIDEO.getMinBytes()) {
248 public String toString() {
257 static List<FileSize> getOptionsForImages() {
258 return Arrays.asList(XXLARGE_IMAGE, XLARGE_IMAGE, LARGE_IMAGE, MEDIUM_IMAGE, SMALL_IMAGE, XSMALL_IMAGE);
266 static List<FileSize> getOptionsForVideos() {
267 return Arrays.asList(XXLARGE_VIDEO, XLARGE_VIDEO, LARGE_VIDEO, MEDIUM_VIDEO, SMALL_VIDEO, XSMALL_VIDEO);
272 private static final ImmutableSet<String> DOCUMENT_MIME_TYPES
273 =
new ImmutableSet.Builder<String>()
278 "application/xhtml+xml",
279 "application/x-msoffice",
280 "application/msword",
281 "application/msword2",
282 "application/vnd.wordperfect",
283 "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
284 "application/vnd.ms-powerpoint",
285 "application/vnd.openxmlformats-officedocument.presentationml.presentation",
286 "application/vnd.ms-excel",
287 "application/vnd.ms-excel.sheet.4",
288 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
289 "application/vnd.oasis.opendocument.presentation",
290 "application/vnd.oasis.opendocument.spreadsheet",
291 "application/vnd.oasis.opendocument.text"
294 private static final ImmutableSet<String> IMAGE_UNSUPPORTED_DOC_TYPES
295 =
new ImmutableSet.Builder<String>()
296 .add(
"application/pdf",
297 "application/xhtml+xml").build();
299 static Collection<String> getDocTypesWithoutImageExtraction(){
300 return Collections.unmodifiableCollection(IMAGE_UNSUPPORTED_DOC_TYPES);
309 "FileSearchData.FileType.Audio.displayName=Audio",
310 "FileSearchData.FileType.Video.displayName=Video",
311 "FileSearchData.FileType.Image.displayName=Image",
312 "FileSearchData.FileType.Documents.displayName=Documents",
313 "FileSearchData.FileType.Executables.displayName=Executables",
314 "FileSearchData.FileType.Other.displayName=Other/Unknown"})
317 IMAGE(0, Bundle.FileSearchData_FileType_Image_displayName(), FileTypeUtils.FileTypeCategory.IMAGE.getMediaTypes()),
318 AUDIO(1, Bundle.FileSearchData_FileType_Audio_displayName(), FileTypeUtils.FileTypeCategory.AUDIO.getMediaTypes()),
319 VIDEO(2, Bundle.FileSearchData_FileType_Video_displayName(), FileTypeUtils.FileTypeCategory.VIDEO.getMediaTypes()),
320 EXECUTABLE(3, Bundle.FileSearchData_FileType_Executables_displayName(), FileTypeUtils.FileTypeCategory.EXECUTABLE.getMediaTypes()),
321 DOCUMENTS(4, Bundle.FileSearchData_FileType_Documents_displayName(), DOCUMENT_MIME_TYPES),
322 OTHER(5, Bundle.FileSearchData_FileType_Other_displayName(),
new ArrayList<>());
324 private final int ranking;
325 private final String displayName;
326 private final Collection<String> mediaTypes;
328 FileType(
int value, String displayName, Collection<String> mediaTypes) {
329 this.ranking = value;
330 this.displayName = displayName;
331 this.mediaTypes = mediaTypes;
339 Collection<String> getMediaTypes() {
340 return Collections.unmodifiableCollection(mediaTypes);
344 public String toString() {
364 static FileType fromMIMEtype(String mimeType) {
365 for (FileType type : FileType.values()) {
366 if (type.getMediaTypes().contains(mimeType)) {
378 static List<FileType> getOptionsForFiltering() {
379 return Arrays.asList(IMAGE, VIDEO);
387 "FileSearchData.Score.notable.displayName=Notable",
388 "FileSearchData.Score.interesting.displayName=Interesting",
389 "FileSearchData.Score.unknown.displayName=Unknown",})
391 NOTABLE(0, Bundle.FileSearchData_Score_notable_displayName()),
392 INTERESTING(1, Bundle.FileSearchData_Score_interesting_displayName()),
393 UNKNOWN(2, Bundle.FileSearchData_Score_unknown_displayName());
395 private final int ranking;
396 private final String displayName;
398 Score(
int ranking, String displayName) {
399 this.ranking = ranking;
400 this.displayName = displayName;
417 static List<Score> getOptionsForFiltering() {
418 return Arrays.asList(NOTABLE, INTERESTING);
422 public String toString() {
427 private FileSearchData() {