本文整理汇总了Java中net.sf.uadetector.ReadableUserAgent.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ReadableUserAgent.getName方法的具体用法?Java ReadableUserAgent.getName怎么用?Java ReadableUserAgent.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.uadetector.ReadableUserAgent
的用法示例。
在下文中一共展示了ReadableUserAgent.getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Browser
import net.sf.uadetector.ReadableUserAgent; //导入方法依赖的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();
}
}
}
示例2: _getDeviceInfo
import net.sf.uadetector.ReadableUserAgent; //导入方法依赖的package包/类
private DeviceInfo _getDeviceInfo(String userAgent) {
DeviceInfo deviceInfo = new DeviceInfo();
if (userAgent == null) {
return deviceInfo;
}
ReadableUserAgent agent = parser.parse(userAgent);
String deviceCategory = agent.getDeviceCategory().getName();
OperatingSystem operatingSystem = agent.getOperatingSystem();
String osFamily = operatingSystem.getFamilyName();
String osVersion = operatingSystem.getVersionNumber().toVersionString();
String userAgentName = agent.getName();
String userAgentType = agent.getTypeName();
String userAgentFamily = agent.getFamily().getName();
String userAgentVersion = agent.getVersionNumber().toVersionString();
deviceInfo.setDeviceCategory(deviceCategory);
deviceInfo.setOsFamily(osFamily);
deviceInfo.setOsVersion(osVersion);
deviceInfo.setUserAgent(userAgentName);
deviceInfo.setUserAgentType(userAgentType);
deviceInfo.setUserAgentFamily(userAgentFamily);
deviceInfo.setUserAgentVersion(userAgentVersion);
return deviceInfo;
}
示例3: handle
import net.sf.uadetector.ReadableUserAgent; //导入方法依赖的package包/类
@Override
public void handle(String line) {
Matcher matcher = TailService.this.accessLogPattern.matcher(line);
if (!matcher.matches()) {
// System.out.println(line);
return;
}
String ip = matcher.group(1);
if (!"-".equals(ip) && !"127.0.0.1".equals(ip)) {
CityResponse cr = lookupCity(ip);
if (cr != null) {
Access access = new Access();
access.setIp(ip);
access.setDate(Instant.now().toEpochMilli());
access.setCity(cr.getCity().getName());
access.setCountry(cr.getCountry().getName());
String userAgent = matcher.group(9);
ReadableUserAgent ua = TailService.this.parser.parse(userAgent);
if (ua != null && ua.getFamily() != UserAgentFamily.UNKNOWN) {
String uaString = ua.getName() + " "
+ ua.getVersionNumber().toVersionString();
uaString += "; " + ua.getOperatingSystem().getName();
uaString += "; " + ua.getFamily();
uaString += "; " + ua.getTypeName();
uaString += "; " + ua.getProducer();
access.setMessage(matcher.group(4) + "; " + uaString);
}
else {
access.setMessage(null);
}
access.setLl(new Double[] { cr.getLocation().getLatitude(),
cr.getLocation().getLongitude() });
TailService.this.eventMessenger.sendToAll("/queue/geoip", access);
}
}
}