<commit_before>package sg.edu.cs2103aug2015_w13_2j.commands;

import sg.edu.cs2103aug2015_w13_2j.Logic;
import sg.edu.cs2103aug2015_w13_2j.filters.ActiveFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.ArchivedFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.ImportantFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.SearchFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.SortFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.SortFilter.InvalidSortFilterException;
import sg.edu.cs2103aug2015_w13_2j.parser.Command;
import sg.edu.cs2103aug2015_w13_2j.parser.Token;
import sg.edu.cs2103aug2015_w13_2j.ui.FeedbackMessage;
import sg.edu.cs2103aug2015_w13_2j.ui.FeedbackMessage.FeedbackType;

public class FilterHandler extends CommandHandler {
    private static final String NAME = "Add Filter";
    private static final String SYNTAX = "<FILTER_NAME>";
    private static final String[] FLAGS = {};
    private static final String[] OPTIONS = { OPTION_FILTER_NAME };
    private static final String[] RESERVED = { "filter" };
    private static final String FILTER_SUCCESS = "Tasks filtered.";

    public FilterHandler() {
        super(NAME, SYNTAX, FLAGS, OPTIONS, RESERVED);
    }

    @Override
    public void execute(Logic logic, Command command) {
        Token alpha = command.getAlphaToken();
        switch (alpha.value) {
        case "active":
            logic.pushFilter(new ActiveFilter());
            break;
        case "is:archived":
            logic.pushFilter(new ArchivedFilter());
            break;
        case "is:important":
            logic.pushFilter(new ImportantFilter());
            break;
        default:
            String[] filter = alpha.value.split(":", 2);
            if (filter.length == 2) {
                switch (filter[0]) {
                case "search":
                    String needle = filter[1];
                    logic.pushFilter(new SearchFilter(needle));
                    break;
                case "sort":
                    String sortBy = filter[1];
                    try {
                        logic.pushFilter(new SortFilter(sortBy));
                        break;
                    } catch (InvalidSortFilterException e) {
                        // Do nothing, fall through to default case
                    }
                default:
                    logic.feedback(FeedbackMessage.ERROR_INVALID_FILTER);
                }
            } else {
                logic.feedback(FeedbackMessage.ERROR_INVALID_FILTER);
            }
        }
        logic.feedback(new FeedbackMessage(FILTER_SUCCESS, FeedbackType.INFO));
    }
}<commit_msg>Fix for FilterHandler not showing error feedback<commit_after>package sg.edu.cs2103aug2015_w13_2j.commands;

import sg.edu.cs2103aug2015_w13_2j.Logic;
import sg.edu.cs2103aug2015_w13_2j.filters.ActiveFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.ArchivedFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.ImportantFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.SearchFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.SortFilter;
import sg.edu.cs2103aug2015_w13_2j.filters.SortFilter.InvalidSortFilterException;
import sg.edu.cs2103aug2015_w13_2j.parser.Command;
import sg.edu.cs2103aug2015_w13_2j.parser.Token;
import sg.edu.cs2103aug2015_w13_2j.ui.FeedbackMessage;
import sg.edu.cs2103aug2015_w13_2j.ui.FeedbackMessage.FeedbackType;

public class FilterHandler extends CommandHandler {
    private static final String NAME = "Add Filter";
    private static final String SYNTAX = "<FILTER_NAME>";
    private static final String[] FLAGS = {};
    private static final String[] OPTIONS = { OPTION_FILTER_NAME };
    private static final String[] RESERVED = { "filter" };
    private static final String FILTER_SUCCESS = "Tasks filtered.";

    public FilterHandler() {
        super(NAME, SYNTAX, FLAGS, OPTIONS, RESERVED);
    }

    @Override
    public void execute(Logic logic, Command command) {
        Token alpha = command.getAlphaToken();
        switch (alpha.value) {
        case "active":
            logic.pushFilter(new ActiveFilter());
            break;
        case "is:archived":
            logic.pushFilter(new ArchivedFilter());
            break;
        case "is:important":
            logic.pushFilter(new ImportantFilter());
            break;
        default:
            String[] filter = alpha.value.split(":", 2);
            if (filter.length == 2) {
                switch (filter[0]) {
                case "search":
                    String needle = filter[1];
                    logic.pushFilter(new SearchFilter(needle));
                    break;
                case "sort":
                    String sortBy = filter[1];
                    try {
                        logic.pushFilter(new SortFilter(sortBy));
                        break;
                    } catch (InvalidSortFilterException e) {
                        // Do nothing, fall through to default case
                    }
                default:
                    logic.feedback(FeedbackMessage.ERROR_INVALID_FILTER);
                    return;
                }
            } else {
                logic.feedback(FeedbackMessage.ERROR_INVALID_FILTER);
                return;
            }
        }
        logic.feedback(new FeedbackMessage(FILTER_SUCCESS, FeedbackType.INFO));
    }
}
{'fraction_non_alphanumeric': 0.09116383336446852, 'fraction_numerical': 0.05118625070054175, 'mean_word_length': 2.204069419509276, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6741693', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1488, 'n_words': 296}