19 package org.sleuthkit.autopsy.discovery.search;
21 import java.time.DayOfWeek;
22 import java.time.Instant;
23 import java.time.ZonedDateTime;
24 import java.time.temporal.TemporalAdjusters;
25 import java.util.Collections;
27 import java.util.HashSet;
28 import java.util.List;
29 import java.util.Objects;
30 import java.util.TimeZone;
31 import java.util.logging.Level;
32 import org.openide.util.NbBundle;
53 static class SearchKey
implements Comparable<SearchKey> {
55 private final String keyString;
59 private final List<AbstractFilter> filters;
60 private final SleuthkitCase sleuthkitCase;
74 SearchKey(String userName, List<AbstractFilter> filters,
79 this.groupAttributeType = groupAttributeType;
80 this.groupSortingType = groupSortingType;
81 this.sortingMethod = sortingMethod;
82 this.filters = filters;
84 StringBuilder searchStringBuilder =
new StringBuilder();
85 searchStringBuilder.append(userName);
87 searchStringBuilder.append(filter.toString());
89 searchStringBuilder.append(groupAttributeType).append(groupSortingType).append(sortingMethod);
90 keyString = searchStringBuilder.toString();
91 this.sleuthkitCase = sleuthkitCase;
92 this.centralRepository = centralRepository;
105 SearchKey(String userName, List<AbstractFilter> filters,
109 this(userName, filters, groupAttributeType, groupSortingType,
110 sortingMethod, null, null);
114 public int compareTo(SearchKey otherSearchKey) {
115 return getKeyString().compareTo(otherSearchKey.getKeyString());
119 public boolean equals(Object otherKey) {
120 if (otherKey ==
this) {
124 if (!(otherKey instanceof SearchKey)) {
128 SearchKey otherSearchKey = (SearchKey) otherKey;
129 if (this.sleuthkitCase != otherSearchKey.getSleuthkitCase()
130 || this.centralRepository != otherSearchKey.getCentralRepository()) {
134 return getKeyString().equals(otherSearchKey.getKeyString());
138 public int hashCode() {
140 hash = 79 * hash + Objects.hashCode(getKeyString());
149 String getKeyString() {
158 List<AbstractFilter> getFilters() {
159 return Collections.unmodifiableList(this.filters);
168 return groupSortingType;
177 return groupAttributeType;
186 return sortingMethod;
194 SleuthkitCase getSleuthkitCase() {
195 return this.sleuthkitCase;
204 return this.centralRepository;
211 public abstract static class GroupKey implements Comparable<GroupKey> {
219 abstract String getDisplayName();
229 abstract public boolean equals(Object otherKey);
248 int compareClassNames(
GroupKey otherGroupKey) {
249 return this.getClass().getName().compareTo(otherGroupKey.getClass().getName());
254 return getDisplayName();
261 static class FileSizeGroupKey
extends GroupKey {
270 FileSizeGroupKey(
Result file) {
280 String getDisplayName() {
281 return getFileSize().toString();
285 public int compareTo(GroupKey otherGroupKey) {
286 if (otherGroupKey instanceof FileSizeGroupKey) {
287 FileSizeGroupKey otherFileSizeGroupKey = (FileSizeGroupKey) otherGroupKey;
288 return Integer.compare(getFileSize().getRanking(), otherFileSizeGroupKey.getFileSize().getRanking());
290 return compareClassNames(otherGroupKey);
295 public boolean equals(Object otherKey) {
296 if (otherKey ==
this) {
300 if (!(otherKey instanceof FileSizeGroupKey)) {
304 FileSizeGroupKey otherFileSizeGroupKey = (FileSizeGroupKey) otherKey;
305 return getFileSize().equals(otherFileSizeGroupKey.getFileSize());
309 public int hashCode() {
310 return Objects.hash(getFileSize().getRanking());
318 SearchData.FileSize getFileSize() {
326 static class FileTypeGroupKey
extends GroupKey {
328 private final SearchData.Type fileType;
335 FileTypeGroupKey(Result file) {
336 fileType = ((ResultFile) file).getFileType();
340 String getDisplayName() {
341 return getFileType().toString();
345 public int compareTo(GroupKey otherGroupKey) {
346 if (otherGroupKey instanceof FileTypeGroupKey) {
347 FileTypeGroupKey otherFileTypeGroupKey = (FileTypeGroupKey) otherGroupKey;
348 return Integer.compare(getFileType().getRanking(), otherFileTypeGroupKey.getFileType().getRanking());
350 return compareClassNames(otherGroupKey);
355 public boolean equals(Object otherKey) {
356 if (otherKey ==
this) {
360 if (!(otherKey instanceof FileTypeGroupKey)) {
364 FileTypeGroupKey otherFileTypeGroupKey = (FileTypeGroupKey) otherKey;
365 return getFileType().equals(otherFileTypeGroupKey.getFileType());
369 public int hashCode() {
370 return Objects.hash(getFileType().getRanking());
378 SearchData.Type getFileType() {
386 static class KeywordListGroupKey
extends GroupKey {
388 private final List<String> keywordListNames;
389 private final String keywordListNamesString;
397 "DiscoveryKeyUtils.KeywordListGroupKey.noKeywords=None"})
398 KeywordListGroupKey(ResultFile file) {
399 keywordListNames = file.getKeywordListNames();
400 if (keywordListNames.isEmpty()) {
401 keywordListNamesString = Bundle.DiscoveryKeyUtils_KeywordListGroupKey_noKeywords();
403 keywordListNamesString = String.join(
",", keywordListNames);
408 String getDisplayName() {
409 return getKeywordListNamesString();
413 public int compareTo(GroupKey otherGroupKey) {
414 if (otherGroupKey instanceof KeywordListGroupKey) {
415 KeywordListGroupKey otherKeywordListNamesGroupKey = (KeywordListGroupKey) otherGroupKey;
418 if (getKeywordListNames().isEmpty()) {
419 if (otherKeywordListNamesGroupKey.getKeywordListNames().isEmpty()) {
424 }
else if (otherKeywordListNamesGroupKey.getKeywordListNames().isEmpty()) {
428 return getKeywordListNamesString().compareTo(otherKeywordListNamesGroupKey.getKeywordListNamesString());
430 return compareClassNames(otherGroupKey);
435 public boolean equals(Object otherKey) {
436 if (otherKey ==
this) {
440 if (!(otherKey instanceof KeywordListGroupKey)) {
444 KeywordListGroupKey otherKeywordListGroupKey = (KeywordListGroupKey) otherKey;
445 return getKeywordListNamesString().equals(otherKeywordListGroupKey.getKeywordListNamesString());
449 public int hashCode() {
450 return Objects.hash(getKeywordListNamesString());
458 List<String> getKeywordListNames() {
459 return Collections.unmodifiableList(keywordListNames);
469 String getKeywordListNamesString() {
470 return keywordListNamesString;
477 static class FileTagGroupKey
extends GroupKey {
479 private final List<String> tagNames;
480 private final String tagNamesString;
488 "DiscoveryKeyUtils.FileTagGroupKey.noSets=None"})
489 FileTagGroupKey(ResultFile file) {
490 tagNames = file.getTagNames();
492 if (tagNames.isEmpty()) {
493 tagNamesString = Bundle.DiscoveryKeyUtils_FileTagGroupKey_noSets();
495 tagNamesString = String.join(
",", tagNames);
500 String getDisplayName() {
501 return getTagNamesString();
505 public int compareTo(GroupKey otherGroupKey) {
506 if (otherGroupKey instanceof FileTagGroupKey) {
507 FileTagGroupKey otherFileTagGroupKey = (FileTagGroupKey) otherGroupKey;
510 if (getTagNames().isEmpty()) {
511 if (otherFileTagGroupKey.getTagNames().isEmpty()) {
516 }
else if (otherFileTagGroupKey.getTagNames().isEmpty()) {
520 return getTagNamesString().compareTo(otherFileTagGroupKey.getTagNamesString());
522 return compareClassNames(otherGroupKey);
527 public boolean equals(Object otherKey) {
528 if (otherKey ==
this) {
531 if (!(otherKey instanceof FileTagGroupKey)) {
534 FileTagGroupKey otherFileTagGroupKey = (FileTagGroupKey) otherKey;
535 return getTagNamesString().equals(otherFileTagGroupKey.getTagNamesString());
539 public int hashCode() {
540 return Objects.hash(getTagNamesString());
548 List<String> getTagNames() {
549 return Collections.unmodifiableList(tagNames);
559 String getTagNamesString() {
560 return tagNamesString;
567 static class ParentPathGroupKey
extends GroupKey {
569 private String parentPath;
570 private Long parentID;
577 ParentPathGroupKey(ResultFile file) {
580 parent = file.getFirstInstance().getParent();
581 }
catch (TskCoreException ignored) {
585 while (parent != null && parent instanceof AbstractFile && ((AbstractFile) parent).isFile()) {
587 parent = parent.getParent();
588 }
catch (TskCoreException ignored) {
592 setParentPathAndID(parent, file);
601 private void setParentPathAndID(Content parent, ResultFile file) {
602 if (parent != null) {
604 parentPath = parent.getUniquePath();
605 parentID = parent.getId();
606 }
catch (TskCoreException ignored) {
611 if (parentPath == null) {
612 if (file.getFirstInstance().getParentPath() != null) {
613 parentPath = file.getFirstInstance().getParentPath();
622 String getDisplayName() {
623 return getParentPath();
627 public int compareTo(GroupKey otherGroupKey) {
628 if (otherGroupKey instanceof ParentPathGroupKey) {
629 ParentPathGroupKey otherParentPathGroupKey = (ParentPathGroupKey) otherGroupKey;
630 int comparisonResult = getParentPath().compareTo(otherParentPathGroupKey.getParentPath());
631 if (comparisonResult == 0) {
632 comparisonResult = getParentID().compareTo(otherParentPathGroupKey.getParentID());
634 return comparisonResult;
636 return compareClassNames(otherGroupKey);
641 public boolean equals(Object otherKey) {
642 if (otherKey ==
this) {
646 if (!(otherKey instanceof ParentPathGroupKey)) {
650 ParentPathGroupKey otherParentPathGroupKey = (ParentPathGroupKey) otherKey;
651 return getParentPath().equals(otherParentPathGroupKey.getParentPath()) && getParentID().equals(otherParentPathGroupKey.getParentID());
655 public int hashCode() {
657 hashCode = 61 * hashCode + Objects.hash(getParentPath());
658 hashCode = 61 * hashCode + Objects.hash(getParentID());
667 String getParentPath() {
684 static class DataSourceGroupKey
extends GroupKey {
686 private final long dataSourceID;
687 private String displayName;
695 "# {0} - Data source name",
696 "# {1} - Data source ID",
697 "DiscoveryKeyUtils.DataSourceGroupKey.datasourceAndID={0}(ID: {1})",
698 "# {0} - Data source ID",
699 "DiscoveryKeyUtils.DataSourceGroupKey.idOnly=Data source (ID: {0})"})
700 DataSourceGroupKey(Result result) {
702 dataSourceID = result.getDataSourceObjectId();
705 Content ds = result.getDataSource();
706 displayName = Bundle.DiscoveryKeyUtils_DataSourceGroupKey_datasourceAndID(ds.getName(), ds.getId());
707 }
catch (TskCoreException ex) {
708 logger.log(Level.WARNING,
"Error looking up data source with ID " + dataSourceID, ex);
709 displayName = Bundle.DiscoveryKeyUtils_DataSourceGroupKey_idOnly(dataSourceID);
714 String getDisplayName() {
719 public int compareTo(GroupKey otherGroupKey) {
720 if (otherGroupKey instanceof DataSourceGroupKey) {
721 DataSourceGroupKey otherDataSourceGroupKey = (DataSourceGroupKey) otherGroupKey;
722 return Long.compare(getDataSourceID(), otherDataSourceGroupKey.getDataSourceID());
724 return compareClassNames(otherGroupKey);
729 public boolean equals(Object otherKey) {
730 if (otherKey ==
this) {
734 if (!(otherKey instanceof DataSourceGroupKey)) {
738 DataSourceGroupKey otherDataSourceGroupKey = (DataSourceGroupKey) otherKey;
739 return getDataSourceID() == otherDataSourceGroupKey.getDataSourceID();
743 public int hashCode() {
744 return Objects.hash(getDataSourceID());
752 long getDataSourceID() {
761 static class NoGroupingGroupKey
extends GroupKey {
766 NoGroupingGroupKey() {
771 "DiscoveryKeyUtils.NoGroupingGroupKey.allFiles=All Files"})
773 String getDisplayName() {
774 return Bundle.DiscoveryKeyUtils_NoGroupingGroupKey_allFiles();
778 public int compareTo(GroupKey otherGroupKey) {
780 if (otherGroupKey instanceof NoGroupingGroupKey) {
783 return compareClassNames(otherGroupKey);
788 public boolean equals(Object otherKey) {
789 if (otherKey ==
this) {
793 return otherKey instanceof NoGroupingGroupKey;
797 public int hashCode() {
805 static class DomainCategoryGroupKey
extends GroupKey {
807 private final Set<String> webCategories =
new HashSet<>();
808 private final String displayName;
810 DomainCategoryGroupKey(Result result) {
811 if (result instanceof ResultDomain) {
812 ResultDomain domain = (ResultDomain) result;
813 this.webCategories.addAll(domain.getWebCategories());
814 displayName = String.join(
",", webCategories);
816 throw new IllegalArgumentException(
"Input result should be of type ResultDomain");
821 String getDisplayName() {
823 return this.displayName;
827 public boolean equals(Object otherKey) {
828 if (otherKey instanceof GroupKey) {
829 return compareTo((GroupKey) otherKey) == 0;
835 public int hashCode() {
836 return Objects.hash(webCategories);
840 public int compareTo(GroupKey otherGroupKey) {
841 if (otherGroupKey instanceof DomainCategoryGroupKey) {
842 if (webCategories.size() != ((DomainCategoryGroupKey) otherGroupKey).getWebCategories().size()) {
845 if (webCategories.containsAll(((DomainCategoryGroupKey) otherGroupKey).getWebCategories())) {
851 return compareClassNames(otherGroupKey);
855 Set<String> getWebCategories() {
856 return Collections.unmodifiableSet(webCategories);
863 static class PreviouslyNotableGroupKey
extends GroupKey {
865 private final SearchData.PreviouslyNotable notableStatus;
867 PreviouslyNotableGroupKey(Result result) {
868 this.notableStatus = result.getPreviouslyNotableInCR();
872 String getDisplayName() {
873 return this.notableStatus.toString();
877 public boolean equals(Object otherKey) {
878 if (otherKey instanceof GroupKey) {
879 return compareTo((GroupKey) otherKey) == 0;
885 public int hashCode() {
886 return Objects.hash(getStatus().getRanking());
890 public int compareTo(GroupKey otherGroupKey) {
891 if (otherGroupKey instanceof PreviouslyNotableGroupKey) {
892 PreviouslyNotableGroupKey otherFrequencyGroupKey = (PreviouslyNotableGroupKey) otherGroupKey;
893 return Integer.compare(getStatus().getRanking(), otherFrequencyGroupKey.getStatus().getRanking());
895 return compareClassNames(otherGroupKey);
899 SearchData.PreviouslyNotable getStatus() {
900 return notableStatus;
907 static class FrequencyGroupKey
extends GroupKey {
909 private final SearchData.Frequency frequency;
916 FrequencyGroupKey(Result result) {
917 frequency = result.getFrequency();
921 String getDisplayName() {
922 return getFrequency().toString();
926 public int compareTo(GroupKey otherGroupKey) {
927 if (otherGroupKey instanceof FrequencyGroupKey) {
928 FrequencyGroupKey otherFrequencyGroupKey = (FrequencyGroupKey) otherGroupKey;
929 return Integer.compare(getFrequency().getRanking(), otherFrequencyGroupKey.getFrequency().getRanking());
931 return compareClassNames(otherGroupKey);
936 public boolean equals(Object otherKey) {
937 if (otherKey ==
this) {
941 if (!(otherKey instanceof FrequencyGroupKey)) {
945 FrequencyGroupKey otherFrequencyGroupKey = (FrequencyGroupKey) otherKey;
946 return getFrequency().equals(otherFrequencyGroupKey.getFrequency());
950 public int hashCode() {
951 return Objects.hash(getFrequency().getRanking());
959 SearchData.Frequency getFrequency() {
967 static class HashHitsGroupKey
extends GroupKey {
969 private final List<String> hashSetNames;
970 private final String hashSetNamesString;
978 "DiscoveryKeyUtils.HashHitsGroupKey.noHashHits=None"})
979 HashHitsGroupKey(ResultFile file) {
980 hashSetNames = file.getHashSetNames();
982 if (hashSetNames.isEmpty()) {
983 hashSetNamesString = Bundle.DiscoveryKeyUtils_HashHitsGroupKey_noHashHits();
985 hashSetNamesString = String.join(
",", hashSetNames);
990 String getDisplayName() {
991 return getHashSetNamesString();
995 public int compareTo(GroupKey otherGroupKey) {
996 if (otherGroupKey instanceof HashHitsGroupKey) {
997 HashHitsGroupKey otherHashHitsGroupKey = (HashHitsGroupKey) otherGroupKey;
1000 if (getHashSetNames().isEmpty()) {
1001 if (otherHashHitsGroupKey.getHashSetNames().isEmpty()) {
1006 }
else if (otherHashHitsGroupKey.getHashSetNames().isEmpty()) {
1010 return getHashSetNamesString().compareTo(otherHashHitsGroupKey.getHashSetNamesString());
1012 return compareClassNames(otherGroupKey);
1017 public boolean equals(Object otherKey) {
1018 if (otherKey ==
this) {
1022 if (!(otherKey instanceof HashHitsGroupKey)) {
1026 HashHitsGroupKey otherHashHitsGroupKey = (HashHitsGroupKey) otherKey;
1027 return getHashSetNamesString().equals(otherHashHitsGroupKey.getHashSetNamesString());
1031 public int hashCode() {
1032 return Objects.hash(getHashSetNamesString());
1040 List<String> getHashSetNames() {
1041 return Collections.unmodifiableList(hashSetNames);
1049 String getHashSetNamesString() {
1050 return hashSetNamesString;
1057 static class InterestingItemGroupKey
extends GroupKey {
1059 private final List<String> interestingItemSetNames;
1060 private final String interestingItemSetNamesString;
1067 @NbBundle.Messages({
1068 "DiscoveryKeyUtils.InterestingItemGroupKey.noSets=None"})
1069 InterestingItemGroupKey(ResultFile file) {
1070 interestingItemSetNames = file.getInterestingSetNames();
1072 if (interestingItemSetNames.isEmpty()) {
1073 interestingItemSetNamesString = Bundle.DiscoveryKeyUtils_InterestingItemGroupKey_noSets();
1075 interestingItemSetNamesString = String.join(
",", interestingItemSetNames);
1080 String getDisplayName() {
1081 return getInterestingItemSetNamesString();
1085 public int compareTo(GroupKey otherGroupKey) {
1086 if (otherGroupKey instanceof InterestingItemGroupKey) {
1087 InterestingItemGroupKey otherInterestingItemGroupKey = (InterestingItemGroupKey) otherGroupKey;
1090 if (this.getInterestingItemSetNames().isEmpty()) {
1091 if (otherInterestingItemGroupKey.getInterestingItemSetNames().isEmpty()) {
1096 }
else if (otherInterestingItemGroupKey.getInterestingItemSetNames().isEmpty()) {
1100 return getInterestingItemSetNamesString().compareTo(otherInterestingItemGroupKey.getInterestingItemSetNamesString());
1102 return compareClassNames(otherGroupKey);
1107 public boolean equals(Object otherKey) {
1108 if (otherKey ==
this) {
1112 if (!(otherKey instanceof InterestingItemGroupKey)) {
1116 InterestingItemGroupKey otherInterestingItemGroupKey = (InterestingItemGroupKey) otherKey;
1117 return getInterestingItemSetNamesString().equals(otherInterestingItemGroupKey.getInterestingItemSetNamesString());
1121 public int hashCode() {
1122 return Objects.hash(getInterestingItemSetNamesString());
1130 List<String> getInterestingItemSetNames() {
1131 return Collections.unmodifiableList(interestingItemSetNames);
1141 String getInterestingItemSetNamesString() {
1142 return interestingItemSetNamesString;
1149 static class LastActivityDateGroupKey
extends GroupKey {
1151 private ZonedDateTime currentWeekCutOff;
1158 LastActivityDateGroupKey(Result result) {
1159 if (result instanceof ResultDomain) {
1160 ResultDomain domainResult = ((ResultDomain) result);
1163 throw new IllegalArgumentException(
"Expected a domain result only.");
1167 @NbBundle.Messages({
1168 "# {0} - month abbreviation",
1169 "# {1} - day of month",
1171 "DiscoveryAttributes.ActivityDateGroupKey.getDisplayNameTemplate=Week of {0} {1}, {2}"
1174 String getDisplayName() {
1175 MonthAbbreviation currentCutOffMonth = MonthAbbreviation.fromMonthValue(currentWeekCutOff.getMonthValue());
1176 return Bundle.DiscoveryAttributes_ActivityDateGroupKey_getDisplayNameTemplate(
1177 currentCutOffMonth.toString(), Integer.toString(currentWeekCutOff.getDayOfMonth()),
1178 Integer.toString(currentWeekCutOff.getYear()));
1182 public boolean equals(Object otherKey) {
1183 if (otherKey ==
this) {
1187 if (!(otherKey instanceof LastActivityDateGroupKey)) {
1191 LastActivityDateGroupKey dateGroupKey = (LastActivityDateGroupKey) otherKey;
1192 return getDisplayName().equals(dateGroupKey.getDisplayName());
1196 public int hashCode() {
1197 return Objects.hash(getDisplayName());
1201 public int compareTo(GroupKey otherGroupKey) {
1202 if (otherGroupKey instanceof LastActivityDateGroupKey) {
1203 LastActivityDateGroupKey otherDateGroupKey = (LastActivityDateGroupKey) otherGroupKey;
1204 return Long.compare(otherDateGroupKey.currentWeekCutOff.toEpochSecond(), currentWeekCutOff.toEpochSecond());
1206 return compareClassNames(otherGroupKey);
1217 Instant startActivityAsInsant = Instant.ofEpochSecond(epochSeconds);
1222 ZonedDateTime startActivityAsDateTime = ZonedDateTime.ofInstant(startActivityAsInsant, currentTimeZone.toZoneId());
1225 return startActivityAsDateTime.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
1231 static class FirstActivityDateGroupKey
extends GroupKey {
1233 private ZonedDateTime currentWeekCutOff;
1240 FirstActivityDateGroupKey(
Result result) {
1241 if (result instanceof ResultDomain) {
1242 ResultDomain domainResult = ((ResultDomain) result);
1245 throw new IllegalArgumentException(
"Expected a domain result only.");
1250 String getDisplayName() {
1251 MonthAbbreviation currentCutOffMonth = MonthAbbreviation.fromMonthValue(currentWeekCutOff.getMonthValue());
1252 return Bundle.DiscoveryAttributes_ActivityDateGroupKey_getDisplayNameTemplate(
1253 currentCutOffMonth.toString(), Integer.toString(currentWeekCutOff.getDayOfMonth()),
1254 Integer.toString(currentWeekCutOff.getYear()));
1258 public boolean equals(Object otherKey) {
1259 if (otherKey ==
this) {
1263 if (!(otherKey instanceof FirstActivityDateGroupKey)) {
1267 FirstActivityDateGroupKey dateGroupKey = (FirstActivityDateGroupKey) otherKey;
1268 return getDisplayName().equals(dateGroupKey.getDisplayName());
1272 public int hashCode() {
1273 return Objects.hash(getDisplayName());
1277 public int compareTo(GroupKey otherGroupKey) {
1278 if (otherGroupKey instanceof FirstActivityDateGroupKey) {
1279 FirstActivityDateGroupKey otherDateGroupKey = (FirstActivityDateGroupKey) otherGroupKey;
1280 return Long.compare(otherDateGroupKey.currentWeekCutOff.toEpochSecond(), currentWeekCutOff.toEpochSecond());
1282 return compareClassNames(otherGroupKey);
1291 static class PageViewsGroupKey
extends GroupKey {
1293 private final String displayName;
1294 private final PageViews pageViews;
1301 PageViewsGroupKey(Result result) {
1302 if (result instanceof ResultDomain) {
1303 Long totalPageViews = ((ResultDomain) result).getTotalPageViews();
1304 if (totalPageViews == null) {
1305 totalPageViews = 0L;
1307 pageViews = PageViews.fromPageViewCount(totalPageViews);
1308 displayName = pageViews.toString();
1310 throw new IllegalArgumentException(
"Expected a domain instance only.");
1315 String getDisplayName() {
1320 public int hashCode() {
1321 return Objects.hash(displayName);
1329 PageViews getPageViews() {
1334 public boolean equals(Object otherKey) {
1335 if (otherKey ==
this) {
1339 if (!(otherKey instanceof PageViewsGroupKey)) {
1343 PageViewsGroupKey pageViewsKey = (PageViewsGroupKey) otherKey;
1344 return pageViews.equals(pageViewsKey.getPageViews());
1348 public int compareTo(GroupKey otherGroupKey) {
1349 if (otherGroupKey instanceof PageViewsGroupKey) {
1350 PageViewsGroupKey pageViewsKey = (PageViewsGroupKey) otherGroupKey;
1351 return getPageViews().compareTo(pageViewsKey.getPageViews());
1353 return compareClassNames(otherGroupKey);
1361 static class ObjectDetectedGroupKey
extends GroupKey {
1363 private final List<String> objectDetectedNames;
1364 private final String objectDetectedNamesString;
1371 @NbBundle.Messages({
1372 "DiscoveryKeyUtils.ObjectDetectedGroupKey.noSets=None"})
1373 ObjectDetectedGroupKey(ResultFile file) {
1374 objectDetectedNames = file.getObjectDetectedNames();
1375 if (objectDetectedNames.isEmpty()) {
1376 objectDetectedNamesString = Bundle.DiscoveryKeyUtils_ObjectDetectedGroupKey_noSets();
1378 objectDetectedNamesString = String.join(
",", objectDetectedNames);
1383 String getDisplayName() {
1384 return getObjectDetectedNamesString();
1388 public int compareTo(GroupKey otherGroupKey) {
1389 if (otherGroupKey instanceof ObjectDetectedGroupKey) {
1390 ObjectDetectedGroupKey otherObjectDetectedGroupKey = (ObjectDetectedGroupKey) otherGroupKey;
1393 if (this.getObjectDetectedNames().isEmpty()) {
1394 if (otherObjectDetectedGroupKey.getObjectDetectedNames().isEmpty()) {
1399 }
else if (otherObjectDetectedGroupKey.getObjectDetectedNames().isEmpty()) {
1403 return getObjectDetectedNamesString().compareTo(otherObjectDetectedGroupKey.getObjectDetectedNamesString());
1405 return compareClassNames(otherGroupKey);
1410 public boolean equals(Object otherKey) {
1411 if (otherKey ==
this) {
1415 if (!(otherKey instanceof ObjectDetectedGroupKey)) {
1419 ObjectDetectedGroupKey otherObjectDetectedGroupKey = (ObjectDetectedGroupKey) otherKey;
1420 return getObjectDetectedNamesString().equals(otherObjectDetectedGroupKey.getObjectDetectedNamesString());
1424 public int hashCode() {
1425 return Objects.hash(getObjectDetectedNamesString());
1433 List<String> getObjectDetectedNames() {
1434 return Collections.unmodifiableList(objectDetectedNames);
1444 String getObjectDetectedNamesString() {
1445 return objectDetectedNamesString;
static final Logger logger
static FileSize fromVideoSize(long size)
abstract boolean equals(Object otherKey)
AbstractFile getFirstInstance()
FileSize(int ranking, long minB, long maxB, String displayName, String displaySize)
synchronized static Logger getLogger(String name)
static ZonedDateTime getCurrentWeekCutOff(long epochSeconds, ResultDomain domainResult)
static TimeZone getTimeZone()