All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.bitwalker.useragentutils.VersionFetcherFromMap Maven / Gradle / Ivy

The newest version!
package eu.bitwalker.useragentutils;

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
 */
class VersionFetcherFromMap extends PatternBasedVersionFetcher {
	private final Map versions;
	
	VersionFetcherFromMap(Pattern pattern, Map versions) {
		super(pattern);
		this.versions = Collections.unmodifiableMap(versions);
	}

	protected Version createVersion(Matcher matcher) {
		return versions.get(matcher.group(1));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy