A fast User Agent parser library, using data from user-agent-string.info
UASparser is available via Maven Central:
- Group ID:
cz.mallat.uasparser
- Artifact ID:
uasparser
View the latest artifact info.
Simply use UASparser or any of its subclasses like so:
UASparser parser = new UASparser();
OnlineUpdater updater = new OnlineUpdater(parser);
UserAgentInfo info = parser.parse("Mozilla/4.0 (compatible; MSIE 7.0;
Windows NT 5.1; )");
This will create a new parser and initialize it with a bundled copy of the database. The
OnlineUpdater
will then asynchronously fetch the latest database in the
background, making it available after a few seconds and caching it locally as well. See
it's source for more on how it works.
In addition, there are a few different parser classes available:
UASparser
- Default parser, thread-safeMultithreadedUASparser
- A faster variant of UASparser, uses a bit more memorySingleThreadedUASparser
- Non-threadsafe variant, ideal for Hadoop and similar use casesBrowserFamilyParser
- UASparser subclass which only returns the browser family string
Building requires Apache buildr:
$ [sudo] gem install buildr
To build UASparser:
$ git clone https://github.com/chetan/UASparser.git
$ cd UASparser
$ buildr package
Binaries will be placed in target
.
- Now available via Maven Central
- added support for the [device] and [device_reg] sections
- Handle version API errors (issue #3)
- Defer initial update on startup (don't block)
- Apply jitter after every update
-
Added UserAgentInfo#getBrowserVersionInfo() method
-
Documented all UserAgentInfo reader methods
-
Added a new, fast, thread-safe MultithreadedUASparser (thanks to Michael Remme)
-
New OnlineUpdater class replaces the old OnlineUpdateUASparser and CachingOnlineUpdateUASparser classes which are now deprecated
-
OnlineUpdater will fallback to a vendored copy if no cached version exists and update fails
-
Minor bugfixes
LGPL. See LICENSE file for details.