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

io.github.apkcloud.devicedetector.parser.device.ShellTv 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;

/**
 * Class ShellTv
 */
public class ShellTv extends AbstractDeviceParser {

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

    protected String parserName = "shelltv";

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

    /**
     * 解析的 UA 是否被识别为 ShellTv 设备
     *
     * @return boolean
     * @throws Exception
     */
    public boolean isShellTv() throws Exception {
        String regex = "[a-z]+[ _]Shell[ _]\\w{6}|tclwebkit(\\d+[\\.\\d]*)";
        List match = matchUserAgent(regex);

        return match != null;
    }

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

* 有关检测到的电视列表,请参阅 shell_tv.yml * * @return {@code Map | null} */ @Override public Map parse() throws Exception { // 只解析包含片段 {brand} shell 的 UserAgent if (!isShellTv()) { return null; } super.parse(fixtureFile); // 始终将设备类型设置为电视,即使找不到型号/品牌 deviceType = DEVICE_TYPE_TV; return getResult(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy