eu.bitwalker.useragentutils.version.fetcher.VersionFetcherFromMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of user-agent-utils Show documentation
Show all versions of user-agent-utils Show documentation
Utility classes to handle user-agents.
The newest version!
package eu.bitwalker.useragentutils.version.fetcher;
import eu.bitwalker.useragentutils.Version;
import java.util.Collections;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Sometimes version of something is not written clearly in User-Agent string.
* However it is possible to extract version of other component that can be
* mapped to needed version. Concrete example is discovery of version of Safari
* browser by version of Webkit.
*
* @author alexr
*/
public class VersionFetcherFromMap extends PatternBasedVersionFetcher {
private final Map versions;
public VersionFetcherFromMap(Pattern pattern, Map versions) {
super(pattern);
this.versions = Collections.unmodifiableMap(versions);
}
protected Version createVersion(Matcher matcher) {
return versions.get(matcher.group(1));
}
}