Go to the documentation of this file.
20package org.sleuthkit.autopsy.commonpropertiessearch;
22import java.util.HashMap;
25import java.util.stream.Collectors;
26import org.openide.util.NbBundle;
31class UserInputErrorManager {
33 static final int FREQUENCY_PERCENTAGE_OUT_OF_RANGE_KEY = 1;
34 static final int NO_FILE_CATEGORIES_SELECTED_KEY = 2;
36 private final Map<Integer, ErrorMessage> currentErrors;
44 "UserInputErrorManager.frequency=Invalid Frequency Percentage: 0 < % < 100.",
45 "UserInputErrorManager.categories=No file categories are included in the search."})
46 UserInputErrorManager (){
51 this.currentErrors =
new HashMap<>();
52 this.currentErrors.put(FREQUENCY_PERCENTAGE_OUT_OF_RANGE_KEY,
new ErrorMessage(Bundle.UserInputErrorManager_frequency()));
53 this.currentErrors.put(NO_FILE_CATEGORIES_SELECTED_KEY,
new ErrorMessage(Bundle.UserInputErrorManager_categories()));
61 void setError(
int errorId,
boolean errorState){
62 if(this.currentErrors.containsKey(errorId)){
63 this.currentErrors.get(errorId).setStatus(errorState);
65 throw new IllegalArgumentException(String.format(
"The given errorId is not mapped to an ErrorMessage: %s.", errorId));
74 return this.currentErrors.values().stream().anyMatch(errorMessage -> errorMessage.isErrorSet() ==
true);
80 List<String> getErrors(){
81 return this.currentErrors.values().stream()
82 .filter(errorMessage -> errorMessage.isErrorSet() ==
true)
83 .map(ErrorMessage::getMessage)
84 .collect(Collectors.toList());
91 private class ErrorMessage {
110 void setStatus(
boolean status){
126 boolean isErrorSet(){
Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.