Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
/ uap-java8 Public archive

Java8 User Agent parser based on the data maintained at https://github.com/ua-parser/uap-core

Notifications You must be signed in to change notification settings

divolte/uap-java8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User agent string parser based on BrowserScope data

This is a Java8 user agent parser implementation based on the data collected by the uap-core project. In oder to use this parser, you need a version of the the parser database from here: https://github.com/ua-parser/uap-core/blob/master/regexes.yaml. This file is not distributed as part of this repository.

Usage

Parser p = new Parser(
        // Obtain this file from: https://github.com/ua-parser/uap-core/blob/master/regexes.yaml
        // It's not distributed with this project.
        Parser.class.getResourceAsStream("/regexes.yaml"),
        // Leniency flag; the regexes may contain invalid configs
        // By passing in true here; the parser will ignore these
        true);

String input = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) "
             + "AppleWebKit/537.36 (KHTML, like Gecko) "
             + "Chrome/40.0.2214.93 Safari/537.36";

// These classes expose getters for user agent fields.
UserAgent agent = p.parseUserAgent(input);
Device device = p.parseDevice(input);
OperatingSystem os = p.parseOperatingSystem(input);

Dependency

This library is currently not published in Maven Central, but likely will be soon.

About

Java8 User Agent parser based on the data maintained at https://github.com/ua-parser/uap-core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages