20 package org.sleuthkit.autopsy.commonpropertiessearch;
 
   22 import java.util.HashMap;
 
   23 import java.util.List;
 
   25 import java.util.stream.Collectors;
 
   26 import org.openide.util.NbBundle;
 
   31 class 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());
 
  110         void setStatus(
boolean status){
 
  126         boolean isErrorSet(){