19 package org.sleuthkit.autopsy.discovery;
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.displayName=XXLarge",
130 "FileSearchData.FileSize.XLARGE.displayName=XLarge",
131 "FileSearchData.FileSize.LARGE.displayName=Large",
132 "FileSearchData.FileSize.MEDIUM.displayName=Medium",
133 "FileSearchData.FileSize.SMALL.displayName=Small",
134 "FileSearchData.FileSize.XSMALL.displayName=XSmall",
135 "FileSearchData.FileSize.10PlusGb=: 10GB+",
136 "FileSearchData.FileSize.5gbto10gb=: 5-10GB",
137 "FileSearchData.FileSize.1gbto5gb=: 1-5GB",
138 "FileSearchData.FileSize.100mbto1gb=: 100MB-1GB",
139 "FileSearchData.FileSize.200PlusMb=: 200MB+",
140 "FileSearchData.FileSize.50mbto200mb=: 50-200MB",
141 "FileSearchData.FileSize.500kbto100mb=: 500KB-100MB",
142 "FileSearchData.FileSize.1mbto50mb=: 1-50MB",
143 "FileSearchData.FileSize.100kbto1mb=: 100KB-1MB",
144 "FileSearchData.FileSize.16kbto100kb=: 16-100KB",
145 "FileSearchData.FileSize.upTo500kb=: 0-500KB",
146 "FileSearchData.FileSize.upTo16kb=: 0-16KB",})
148 XXLARGE_VIDEO(0, 10000 * BYTES_PER_MB, -1, Bundle.FileSearchData_FileSize_XXLARGE_displayName(), Bundle.FileSearchData_FileSize_10PlusGb()),
149 XLARGE_VIDEO(1, 5000 * BYTES_PER_MB, 10000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_XLARGE_displayName(), Bundle.FileSearchData_FileSize_5gbto10gb()),
150 LARGE_VIDEO(2, 1000 * BYTES_PER_MB, 5000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_LARGE_displayName(), Bundle.FileSearchData_FileSize_1gbto5gb()),
151 MEDIUM_VIDEO(3, 100 * BYTES_PER_MB, 1000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_MEDIUM_displayName(), Bundle.FileSearchData_FileSize_100mbto1gb()),
152 SMALL_VIDEO(4, 500000, 100 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_SMALL_displayName(), Bundle.FileSearchData_FileSize_500kbto100mb()),
153 XSMALL_VIDEO(5, 0, 500000, Bundle.FileSearchData_FileSize_XSMALL_displayName(), Bundle.FileSearchData_FileSize_upTo500kb()),
154 XXLARGE_IMAGE(6, 200 * BYTES_PER_MB, -1, Bundle.FileSearchData_FileSize_XXLARGE_displayName(), Bundle.FileSearchData_FileSize_200PlusMb()),
155 XLARGE_IMAGE(7, 50 * BYTES_PER_MB, 200 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_XLARGE_displayName(), Bundle.FileSearchData_FileSize_50mbto200mb()),
156 LARGE_IMAGE(8, 1 * BYTES_PER_MB, 50 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_LARGE_displayName(), Bundle.FileSearchData_FileSize_1mbto50mb()),
157 MEDIUM_IMAGE(9, 100000, 1 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_MEDIUM_displayName(), Bundle.FileSearchData_FileSize_100kbto1mb()),
158 SMALL_IMAGE(10, 16000, 100000, Bundle.FileSearchData_FileSize_SMALL_displayName(), Bundle.FileSearchData_FileSize_16kbto100kb()),
159 XSMALL_IMAGE(11, 0, 16000, Bundle.FileSearchData_FileSize_XSMALL_displayName(), Bundle.FileSearchData_FileSize_upTo16kb());
161 private final int ranking;
162 private final long minBytes;
163 private final long maxBytes;
164 private final String sizeGroup;
165 private final String displaySize;
166 final static long NO_MAXIMUM = -1;
168 FileSize(
int ranking,
long minB,
long maxB, String displayName, String displaySize) {
169 this.ranking = ranking;
170 this.minBytes = minB;
172 this.maxBytes = maxB;
174 this.maxBytes = NO_MAXIMUM;
176 this.sizeGroup = displayName;
177 this.displaySize = displaySize;
188 static FileSize fromImageSize(
long size) {
189 if (size > XXLARGE_IMAGE.getMinBytes()) {
190 return XXLARGE_IMAGE;
191 }
else if (size > XLARGE_IMAGE.getMinBytes()) {
193 }
else if (size > LARGE_IMAGE.getMinBytes()) {
195 }
else if (size > MEDIUM_IMAGE.getMinBytes()) {
197 }
else if (size > SMALL_IMAGE.getMinBytes()) {
212 static FileSize fromVideoSize(
long size) {
213 if (size > XXLARGE_VIDEO.getMinBytes()) {
214 return XXLARGE_VIDEO;
215 }
else if (size > XLARGE_VIDEO.getMinBytes()) {
217 }
else if (size > LARGE_VIDEO.getMinBytes()) {
219 }
else if (size > MEDIUM_VIDEO.getMinBytes()) {
221 }
else if (size > SMALL_VIDEO.getMinBytes()) {
256 public String toString() {
257 return sizeGroup + displaySize;
260 String getSizeGroup(){
270 static List<FileSize> getDefaultSizeOptions() {
271 return Arrays.asList(XXLARGE_IMAGE, XLARGE_IMAGE, LARGE_IMAGE, MEDIUM_IMAGE, SMALL_IMAGE, XSMALL_IMAGE);
279 static List<FileSize> getOptionsForVideos() {
280 return Arrays.asList(XXLARGE_VIDEO, XLARGE_VIDEO, LARGE_VIDEO, MEDIUM_VIDEO, SMALL_VIDEO, XSMALL_VIDEO);
285 private static final ImmutableSet<String> DOCUMENT_MIME_TYPES
286 =
new ImmutableSet.Builder<String>()
291 "application/xhtml+xml",
292 "application/x-msoffice",
293 "application/msword",
294 "application/msword2",
295 "application/vnd.wordperfect",
296 "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
297 "application/vnd.ms-powerpoint",
298 "application/vnd.openxmlformats-officedocument.presentationml.presentation",
299 "application/vnd.ms-excel",
300 "application/vnd.ms-excel.sheet.4",
301 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
302 "application/vnd.oasis.opendocument.presentation",
303 "application/vnd.oasis.opendocument.spreadsheet",
304 "application/vnd.oasis.opendocument.text"
307 private static final ImmutableSet<String> IMAGE_UNSUPPORTED_DOC_TYPES
308 =
new ImmutableSet.Builder<String>()
309 .add(
"application/pdf",
310 "application/xhtml+xml").build();
312 static Collection<String> getDocTypesWithoutImageExtraction() {
313 return Collections.unmodifiableCollection(IMAGE_UNSUPPORTED_DOC_TYPES);
323 "FileSearchData.FileType.Audio.displayName=Audio",
324 "FileSearchData.FileType.Video.displayName=Video",
325 "FileSearchData.FileType.Image.displayName=Image",
326 "FileSearchData.FileType.Documents.displayName=Documents",
327 "FileSearchData.FileType.Executables.displayName=Executables",
328 "FileSearchData.FileType.Other.displayName=Other/Unknown"})
331 IMAGE(0, Bundle.FileSearchData_FileType_Image_displayName(), FileTypeUtils.FileTypeCategory.IMAGE.getMediaTypes()),
332 AUDIO(1, Bundle.FileSearchData_FileType_Audio_displayName(), FileTypeUtils.FileTypeCategory.AUDIO.getMediaTypes()),
333 VIDEO(2, Bundle.FileSearchData_FileType_Video_displayName(), FileTypeUtils.FileTypeCategory.VIDEO.getMediaTypes()),
334 EXECUTABLE(3, Bundle.FileSearchData_FileType_Executables_displayName(), FileTypeUtils.FileTypeCategory.EXECUTABLE.getMediaTypes()),
335 DOCUMENTS(4, Bundle.FileSearchData_FileType_Documents_displayName(), DOCUMENT_MIME_TYPES),
336 OTHER(5, Bundle.FileSearchData_FileType_Other_displayName(),
new ArrayList<>());
338 private final int ranking;
339 private final String displayName;
340 private final Collection<String> mediaTypes;
342 FileType(
int value, String displayName, Collection<String> mediaTypes) {
343 this.ranking = value;
344 this.displayName = displayName;
345 this.mediaTypes = mediaTypes;
353 Collection<String> getMediaTypes() {
354 return Collections.unmodifiableCollection(mediaTypes);
358 public String toString() {
378 static FileType fromMIMEtype(String mimeType) {
379 for (FileType type : FileType.values()) {
380 if (type.getMediaTypes().contains(mimeType)) {
392 static List<FileType> getOptionsForFiltering() {
393 return Arrays.asList(IMAGE, VIDEO);
401 "FileSearchData.Score.notable.displayName=Notable",
402 "FileSearchData.Score.interesting.displayName=Interesting",
403 "FileSearchData.Score.unknown.displayName=Unknown",})
405 NOTABLE(0, Bundle.FileSearchData_Score_notable_displayName()),
406 INTERESTING(1, Bundle.FileSearchData_Score_interesting_displayName()),
407 UNKNOWN(2, Bundle.FileSearchData_Score_unknown_displayName());
409 private final int ranking;
410 private final String displayName;
412 Score(
int ranking, String displayName) {
413 this.ranking = ranking;
414 this.displayName = displayName;
431 static List<Score> getOptionsForFiltering() {
432 return Arrays.asList(NOTABLE, INTERESTING);
436 public String toString() {
441 private FileSearchData() {