19 package org.sleuthkit.autopsy.filequery;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.List;
26 import org.openide.util.NbBundle;
32 final class FileSearchData {
34 private final static long BYTES_PER_MB = 1000000;
40 "FileSearchData.Frequency.unique.displayName=Unique (1)",
41 "FileSearchData.Frequency.rare.displayName=Rare (2-10)",
42 "FileSearchData.Frequency.common.displayName=Common (11 - 100)",
43 "FileSearchData.Frequency.verycommon.displayName=Very Common (100+)",
44 "FileSearchData.Frequency.known.displayName=Known (NSRL)",
45 "FileSearchData.Frequency.unknown.displayName=Unknown",})
47 UNIQUE(0, 1, Bundle.FileSearchData_Frequency_unique_displayName()),
48 RARE(1, 10, Bundle.FileSearchData_Frequency_rare_displayName()),
49 COMMON(2, 100, Bundle.FileSearchData_Frequency_common_displayName()),
50 VERY_COMMON(3, 0, Bundle.FileSearchData_Frequency_common_displayName()),
51 KNOWN(4, 0, Bundle.FileSearchData_Frequency_known_displayName()),
52 UNKNOWN(5, 0, Bundle.FileSearchData_Frequency_unknown_displayName());
54 private final int ranking;
55 private final String displayName;
56 private final int maxOccur;
58 Frequency(
int ranking,
int maxOccur, String displayName) {
59 this.ranking = ranking;
60 this.maxOccur = maxOccur;
61 this.displayName = displayName;
80 static Frequency fromCount(
long count) {
81 if (count <= UNIQUE.getMaxOccur()) {
83 }
else if (count <= RARE.getMaxOccur()) {
85 }
else if (count <= COMMON.getMaxOccur()) {
97 static List<Frequency> getOptionsForFilteringWithCr() {
98 return Arrays.asList(UNIQUE, RARE, COMMON, VERY_COMMON, KNOWN);
107 static List<Frequency> getOptionsForFilteringWithoutCr() {
108 return Arrays.asList(KNOWN, UNKNOWN);
112 public String toString() {
128 "FileSearchData.FileSize.XXLARGE_IMAGE.displayName=XXLarge: 200MB+",
129 "FileSearchData.FileSize.XLARGE_IMAGE.displayName=XLarge: 50-200MB",
130 "FileSearchData.FileSize.LARGE_IMAGE.displayName=Large: 1-50MB",
131 "FileSearchData.FileSize.MEDIUM_IMAGE.displayName=Medium: 100KB-1MB",
132 "FileSearchData.FileSize.SMALL_IMAGE.displayName=Small: 16-100KB",
133 "FileSearchData.FileSize.XSMALL_IMAGE.displayName=XSmall: 0-16KB",
134 "FileSearchData.FileSize.XXLARGE_VIDEO.displayName=XXLarge: 10GB+",
135 "FileSearchData.FileSize.XLARGE_VIDEO.displayName=XLarge: 5-10GB",
136 "FileSearchData.FileSize.LARGE_VIDEO.displayName=Large: 1-5GB",
137 "FileSearchData.FileSize.MEDIUM_VIDEO.displayName=Medium: 100MB-1GB",
138 "FileSearchData.FileSize.SMALL_VIDEO.displayName=Small: 500KB-100MB",
139 "FileSearchData.FileSize.XSMALL_VIDEO.displayName=XSmall: 0-500KB",})
141 XXLARGE_VIDEO(0, 10000 * BYTES_PER_MB, -1, Bundle.FileSearchData_FileSize_XXLARGE_VIDEO_displayName()),
142 XLARGE_VIDEO(1, 5000 * BYTES_PER_MB, 10000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_XLARGE_VIDEO_displayName()),
143 LARGE_VIDEO(2, 1000 * BYTES_PER_MB, 5000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_LARGE_VIDEO_displayName()),
144 MEDIUM_VIDEO(3, 100 * BYTES_PER_MB, 1000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_MEDIUM_VIDEO_displayName()),
145 SMALL_VIDEO(4, 500000, 100 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_SMALL_VIDEO_displayName()),
146 XSMALL_VIDEO(5, 0, 500000, Bundle.FileSearchData_FileSize_XSMALL_VIDEO_displayName()),
147 XXLARGE_IMAGE(6, 200 * BYTES_PER_MB, -1, Bundle.FileSearchData_FileSize_XXLARGE_IMAGE_displayName()),
148 XLARGE_IMAGE(7, 50 * BYTES_PER_MB, 200 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_XLARGE_IMAGE_displayName()),
149 LARGE_IMAGE(8, 1 * BYTES_PER_MB, 50 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_LARGE_IMAGE_displayName()),
150 MEDIUM_IMAGE(9, 100000, 1 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_MEDIUM_IMAGE_displayName()),
151 SMALL_IMAGE(10, 16000, 100000, Bundle.FileSearchData_FileSize_SMALL_IMAGE_displayName()),
152 XSMALL_IMAGE(11, 0, 16000, Bundle.FileSearchData_FileSize_XSMALL_IMAGE_displayName());
154 private final int ranking;
155 private final long minBytes;
156 private final long maxBytes;
157 private final String displayName;
158 final static long NO_MAXIMUM = -1;
160 FileSize(
int ranking,
long minB,
long maxB, String displayName) {
161 this.ranking = ranking;
162 this.minBytes = minB;
164 this.maxBytes = maxB;
166 this.maxBytes = NO_MAXIMUM;
168 this.displayName = displayName;
179 static FileSize fromImageSize(
long size) {
180 if (size > XXLARGE_IMAGE.getMinBytes()) {
181 return XXLARGE_IMAGE;
182 }
else if (size > XLARGE_IMAGE.getMinBytes()) {
184 }
else if (size > LARGE_IMAGE.getMinBytes()) {
186 }
else if (size > MEDIUM_IMAGE.getMinBytes()) {
188 }
else if (size > SMALL_IMAGE.getMinBytes()) {
203 static FileSize fromVideoSize(
long size) {
204 if (size > XXLARGE_VIDEO.getMinBytes()) {
205 return XXLARGE_VIDEO;
206 }
else if (size > XLARGE_VIDEO.getMinBytes()) {
208 }
else if (size > LARGE_VIDEO.getMinBytes()) {
210 }
else if (size > MEDIUM_VIDEO.getMinBytes()) {
212 }
else if (size > SMALL_VIDEO.getMinBytes()) {
247 public String toString() {
256 static List<FileSize> getOptionsForImages() {
257 return Arrays.asList(XXLARGE_IMAGE, XLARGE_IMAGE, LARGE_IMAGE, MEDIUM_IMAGE, SMALL_IMAGE, XSMALL_IMAGE);
265 static List<FileSize> getOptionsForVideos() {
266 return Arrays.asList(XXLARGE_VIDEO, XLARGE_VIDEO, LARGE_VIDEO, MEDIUM_VIDEO, SMALL_VIDEO, XSMALL_VIDEO);
277 "FileSearchData.FileType.Audio.displayName=Audio",
278 "FileSearchData.FileType.Video.displayName=Video",
279 "FileSearchData.FileType.Image.displayName=Image",
280 "FileSearchData.FileType.Documents.displayName=Documents",
281 "FileSearchData.FileType.Executables.displayName=Executables",
282 "FileSearchData.FileType.Other.displayName=Other/Unknown"})
285 IMAGE(0, Bundle.FileSearchData_FileType_Image_displayName(), FileTypeUtils.FileTypeCategory.IMAGE.getMediaTypes()),
286 AUDIO(1, Bundle.FileSearchData_FileType_Audio_displayName(), FileTypeUtils.FileTypeCategory.AUDIO.getMediaTypes()),
287 VIDEO(2, Bundle.FileSearchData_FileType_Video_displayName(), FileTypeUtils.FileTypeCategory.VIDEO.getMediaTypes()),
288 EXECUTABLE(3, Bundle.FileSearchData_FileType_Executables_displayName(), FileTypeUtils.FileTypeCategory.EXECUTABLE.getMediaTypes()),
289 DOCUMENTS(4, Bundle.FileSearchData_FileType_Documents_displayName(), FileTypeUtils.FileTypeCategory.DOCUMENTS.getMediaTypes()),
290 OTHER(5, Bundle.FileSearchData_FileType_Other_displayName(),
new ArrayList<>());
292 private final int ranking;
293 private final String displayName;
294 private final Collection<String> mediaTypes;
296 FileType(
int value, String displayName, Collection<String> mediaTypes) {
297 this.ranking = value;
298 this.displayName = displayName;
299 this.mediaTypes = mediaTypes;
307 Collection<String> getMediaTypes() {
308 return Collections.unmodifiableCollection(mediaTypes);
312 public String toString() {
332 static FileType fromMIMEtype(String mimeType) {
333 for (FileType type : FileType.values()) {
334 if (type.getMediaTypes().contains(mimeType)) {
346 static List<FileType> getOptionsForFiltering() {
347 return Arrays.asList(IMAGE, VIDEO);
355 "FileSearchData.Score.notable.displayName=Notable",
356 "FileSearchData.Score.interesting.displayName=Interesting",
357 "FileSearchData.Score.unknown.displayName=Unknown",})
359 NOTABLE(0, Bundle.FileSearchData_Score_notable_displayName()),
360 INTERESTING(1, Bundle.FileSearchData_Score_interesting_displayName()),
361 UNKNOWN(2, Bundle.FileSearchData_Score_unknown_displayName());
363 private final int ranking;
364 private final String displayName;
366 Score(
int ranking, String displayName) {
367 this.ranking = ranking;
368 this.displayName = displayName;
385 static List<Score> getOptionsForFiltering() {
386 return Arrays.asList(NOTABLE, INTERESTING);
390 public String toString() {
395 private FileSearchData() {