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

io.github.apkcloud.devicedetector.parser.device.HbbTv Maven / Gradle / Ivy

Go to download

通用设备检测库将解析任何UserAgent并检测浏览器、操作系统、使用的设备(桌面、平板、移动、电视、车载、游戏机等等)、品牌和型号。

There is a newer version: 1.0.7
Show newest version
package io.github.apkcloud.devicedetector.parser.device;

import java.util.List;
import java.util.Map;

/**
 * 用于检测 HbbTV 的设备解析器
 */
public class HbbTv extends AbstractDeviceParser {

    protected String fixtureFile = "regexes/device/televisions.yml";

    protected String parserName = "tv";

    @Override
    public String getName() {
        return parserName;
    }

    /**
     * 解析当前的 UA 并检查是否包含 HbbTv 信息。
     * 

* 有关检测到的电视列表,请参阅 Televisions.yml * * @return {@code Map | null} */ public Map parse() throws Exception { // 只解析包含 hbbtv 片段的 UserAgent if (isHbbTv() == null) { return null; } super.parse(fixtureFile); // 始终将设备类型设置为电视,即使找不到型号/品牌 deviceType = DEVICE_TYPE_TV; return getResult(); } /** * 判断解析的 UA 是否被识别为 HbbTV 设备 * * @return String | null */ public String isHbbTv() throws Exception { String regex = "HbbTV/([1-9]{1}(?:\\.[0-9]{1}){1,2})"; List match = matchUserAgent(regex); return (match != null && match.size() >= 2) ? match.get(1) : null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy