Search in sources :

Example 1 with UselessMatcherException

use of nl.basjes.parse.useragent.analyze.UselessMatcherException in project yauaa by nielsbasjes.

the class AbstractUserAgentAnalyzerDirect method finalizeLoadingRules.

protected void finalizeLoadingRules() {
    logVersion();
    flattener = new UserAgentTreeFlattener(this);
    if (wantedFieldNames != null) {
        int wantedSize = wantedFieldNames.size();
        if (wantedFieldNames.contains(SET_ALL_FIELDS)) {
            wantedSize--;
        }
        LOG.info("Building all needed matchers for the requested {} fields.", wantedSize);
    } else {
        LOG.info("Building all matchers for all possible fields.");
    }
    Map<String, MatcherConfig> matcherConfigs = config.getMatcherConfigs();
    if (matcherConfigs.isEmpty()) {
        throw new InvalidParserConfigurationException("No matchers were loaded at all.");
    }
    allMatchers.clear();
    for (Map.Entry<String, MatcherConfig> matcherConfigEntry : matcherConfigs.entrySet()) {
        MatcherConfig matcherConfig = matcherConfigEntry.getValue();
        try {
            allMatchers.add(new Matcher(this, wantedFieldNames, matcherConfig));
        } catch (UselessMatcherException ume) {
        // skippedMatchers++;
        }
    }
    verifyWeAreNotAskingForImpossibleFields();
    if (!delayInitialization) {
        initializeMatchers();
    }
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Matcher(nl.basjes.parse.useragent.analyze.Matcher) UserAgentTreeFlattener(nl.basjes.parse.useragent.parse.UserAgentTreeFlattener) MatcherConfig(nl.basjes.parse.useragent.config.MatcherConfig) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) UselessMatcherException(nl.basjes.parse.useragent.analyze.UselessMatcherException)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 InvalidParserConfigurationException (nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException)1 Matcher (nl.basjes.parse.useragent.analyze.Matcher)1 UselessMatcherException (nl.basjes.parse.useragent.analyze.UselessMatcherException)1 MatcherConfig (nl.basjes.parse.useragent.config.MatcherConfig)1 UserAgentTreeFlattener (nl.basjes.parse.useragent.parse.UserAgentTreeFlattener)1