当前位置: 首页>>代码示例>>Java>>正文


Java UserAgentStringParser类代码示例

本文整理汇总了Java中net.sf.uadetector.UserAgentStringParser的典型用法代码示例。如果您正苦于以下问题:Java UserAgentStringParser类的具体用法?Java UserAgentStringParser怎么用?Java UserAgentStringParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserAgentStringParser类属于net.sf.uadetector包,在下文中一共展示了UserAgentStringParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Browser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
/**
 * Create browser object.
 */
public Browser() {

    Optional<String> userAgent = BaseUITest.getUserAgent();
    if (userAgent.isPresent() && !userAgent.get().isEmpty()) {
        // Try to parse the UA
        UserAgentStringParser uaParser = UADetectorServiceFactory.getResourceModuleParser();
        ReadableUserAgent agent = uaParser.parse(userAgent.get());

        // Set the params based on this agent
        this.name = agent.getName();
        this.version = agent.getVersionNumber().toVersionString();
        this.device = agent.getDeviceCategory().getName();
        this.platform = agent.getOperatingSystem().getName();
        this.platformVersion = agent.getOperatingSystem().getVersionNumber().toVersionString();

    } else {
        // Fall-back to the Property class
        if (BROWSER.isSpecified()) {
            this.name = BROWSER.getValue().toLowerCase();
        } else {
            this.name = DriverSetup.DEFAULT_BROWSER.toString();
        }
        if (BROWSER_VERSION.isSpecified()) {
            this.version = BROWSER_VERSION.getValue();
        }
        if (DEVICE.isSpecified()) {
            this.device = DEVICE.getValue();
        }
        if (PLATFORM.isSpecified()) {
            this.platform = PLATFORM.getValue();
        }
        if (PLATFORM_VERSION.isSpecified()) {
            this.platformVersion = PLATFORM_VERSION.getValue();
        }
    }
}
 
开发者ID:Frameworkium,项目名称:frameworkium-core,代码行数:40,代码来源:Browser.java

示例2: cache

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
protected UADetectorCache cache(UserAgentStringParser parser) {
	CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder()
			.maximumSize(getMaximumSize())
			.expireAfterWrite(getTimeToLiveInSeconds(), TimeUnit.SECONDS);

	return new GuavaCache(builder, parser);
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:8,代码来源:GuavaCacheParserConfiguration.java

示例3: cache

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
protected UADetectorCache cache(UserAgentStringParser parser) {
	CacheManager cacheManager = CacheManager.getInstance();

	Cache ehCache = cacheManager.getCache("uadetector");
	CacheConfiguration configuration = ehCache.getCacheConfiguration();
	configuration.setMemoryStoreEvictionPolicy("LRU");
	configuration.setMaxEntriesLocalHeap(getMaximumSize());
	configuration.setTimeToLiveSeconds(getTimeToLiveInSeconds());

	return new EhCacheCache(ehCache, parser);
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:12,代码来源:EhCacheParserConfiguration.java

示例4: it_should_build_cached_parser_with_custom_parser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Test
public void it_should_build_cached_parser_with_custom_parser() throws Exception {
	CachedUserAgentStringParser cachedParser = new CachedUserAgentStringParser(parser);

	UserAgentStringParser internalParser = (UserAgentStringParser) readField(cachedParser, "parser", true);
	UADetectorCache internalCache = (UADetectorCache) readField(cachedParser, "cache", true);

	assertThat(internalParser).isNotNull().isSameAs(parser);
	assertThat(internalCache).isNotNull().isExactlyInstanceOf(SimpleCache.class);
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:11,代码来源:CachedUserAgentStringParserTest.java

示例5: it_should_build_simple_cache_with_parser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Test
public void it_should_build_simple_cache_with_parser() throws Exception {
	GuavaCache cache = new GuavaCache(builder, parser);

	UserAgentStringParser internalParser = (UserAgentStringParser) readField(cache, "parser", true);
	LoadingCache<String, ReadableUserAgent> internalCache = (LoadingCache<String, ReadableUserAgent>) readField(cache, "cache", true);

	assertThat(internalParser).isNotNull().isSameAs(parser);
	assertThat(internalCache).isNotNull();
	assertThat(internalCache.size()).isZero();
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:12,代码来源:GuavaCacheTest.java

示例6: it_should_build_simple_cache_with_parser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Test
public void it_should_build_simple_cache_with_parser() throws Exception {
	EhCacheCache cache = new EhCacheCache(ehCache, parser);

	UserAgentStringParser internalParser = (UserAgentStringParser) readField(cache, "parser", true);
	Ehcache internalCache = (Ehcache) readField(cache, "cache", true);

	assertThat(internalParser).isNotNull().isSameAs(parser);
	assertThat(internalCache).isNotNull();
	assertThat(internalCache.getSize()).isZero();
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:12,代码来源:EhCacheCacheTest.java

示例7: it_should_create_entry_factory

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Test
public void it_should_create_entry_factory() throws Exception {
	EhCacheEntryFactory factory = new EhCacheEntryFactory(parser);

	UserAgentStringParser internalParser = (UserAgentStringParser) readField(factory, "parser", true);
	assertThat(internalParser).isNotNull().isSameAs(parser);
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:8,代码来源:EhCacheEntryFactoryTest.java

示例8: it_should_build_simple_cache_with_parser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Test
public void it_should_build_simple_cache_with_parser() throws Exception {
	SimpleCache cache = new SimpleCache(parser);

	UserAgentStringParser internalParser = (UserAgentStringParser) readField(cache, "parser", true);
	ConcurrentMap<String, ReadableUserAgent> internalCache = (ConcurrentMap<String, ReadableUserAgent>) readField(cache, "cache", true);

	assertThat(internalParser).isNotNull().isSameAs(parser);
	assertThat(internalCache).isNotNull().isEmpty();
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:11,代码来源:SimpleCacheTest.java

示例9: addContents

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Override
public void addContents(@NonNull Container result) {
    final StaplerRequest currentRequest = Stapler.getCurrentRequest();
    if (currentRequest != null) {
        result.add(new PrintedContent("browser.md") {
            @Override
            protected void printTo(PrintWriter out) throws IOException {
                out.println("Browser");
                out.println("=======");
                out.println();

                Area screenResolution = Functions.getScreenResolution();
                if (screenResolution != null) {
                    out.println("  * Screen size: " + screenResolution.toString());
                }
                UserAgentStringParser parser = UADetectorServiceFactory.getResourceModuleParser();
                String userAgent = currentRequest.getHeader("User-Agent");
                ReadableUserAgent agent = parser.parse(userAgent);
                OperatingSystem operatingSystem = agent.getOperatingSystem();
                out.println("  * User Agent");
                out.println("      - Type:     " + agent.getType().getName());
                out.println("      - Name:     " + agent.getName());
                out.println("      - Family:   " + agent.getFamily());
                out.println("      - Producer: " + agent.getProducer());
                out.println("      - Version:  " + agent.getVersionNumber().toVersionString());
                out.println("      - Raw:      `" + userAgent.replaceAll("`", "&#96;") + '`');
                out.println("  * Operating System");
                out.println("      - Name:     " + operatingSystem.getName());
                out.println("      - Family:   " + operatingSystem.getFamily());
                out.println("      - Producer: " + operatingSystem.getProducer());
                out.println("      - Version:  " + operatingSystem.getVersionNumber().toVersionString());
                out.println();
            }
        });
    }
}
 
开发者ID:jenkinsci,项目名称:support-core-plugin,代码行数:37,代码来源:AboutBrowser.java

示例10: getUADetectorExample

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
private static ReadableUserAgent getUADetectorExample(String userAgentString) {
    UserAgentStringParser userAgentStringParser = UADetectorServiceFactory.getCachingAndUpdatingParser();
    return userAgentStringParser.parse(userAgentString);
}
 
开发者ID:sdcuike,项目名称:book-reading,代码行数:5,代码来源:DetectDeviceTypeinJavaWebApplicationI.java

示例11: init

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
/**
 * create the executor
 */
public void init() throws ServletException {
	this.ipdb = RuntimeContext.injector().getInstance(IPLocationDB.class);
	this.uagentParser = RuntimeContext.injector().getInstance(UserAgentStringParser.class);
}
 
开发者ID:thmarx,项目名称:InfoService,代码行数:8,代码来源:IPInfoServlet.java

示例12: initUserAgentParser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Provides
@Singleton
private UserAgentStringParser initUserAgentParser () {
	return new CachedUserAgentStringParser();
}
 
开发者ID:thmarx,项目名称:InfoService,代码行数:6,代码来源:DevelomentConfigModule.java

示例13: userAgentStringParser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Bean(destroyMethod = "shutdown")
public UserAgentStringParser userAgentStringParser() {
	return UADetectorServiceFactory.getResourceModuleParser();
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:5,代码来源:NoCacheParserConfiguration.java

示例14: userAgentStringParser

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
@Bean(destroyMethod = "shutdown")
public UserAgentStringParser userAgentStringParser() {
	UserAgentStringParser parser = UADetectorServiceFactory.getResourceModuleParser();
	UADetectorCache cache = cache(parser);
	return new CachedUserAgentStringParser(parser, cache);
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:7,代码来源:AbstractCacheConfiguration.java

示例15: cache

import net.sf.uadetector.UserAgentStringParser; //导入依赖的package包/类
protected UADetectorCache cache(UserAgentStringParser parser) {
	return new SimpleCache(parser);
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:4,代码来源:SimpleCacheParserConfiguration.java


注:本文中的net.sf.uadetector.UserAgentStringParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。