public class UASparser
extends java.lang.Object
MultithreadedUASparser for a faster variant.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.Long,cz.mallat.uasparser.BrowserEntry> |
browserMap |
protected java.util.Map<java.lang.Long,java.lang.Long> |
browserOsMap |
protected java.util.Map<java.lang.String,java.lang.Long> |
browserRegMap |
protected java.util.Map<java.lang.Long,java.lang.String> |
browserTypeMap |
protected java.util.Map<jregex.Pattern,java.lang.Long> |
compiledBrowserRegMap |
protected java.util.Map<jregex.Pattern,java.lang.Long> |
compiledDeviceRegMap |
protected java.util.Map<jregex.Pattern,java.lang.Long> |
compiledOsRegMap |
protected java.util.Map<java.lang.Long,cz.mallat.uasparser.DeviceEntry> |
deviceMap |
protected java.util.Map<java.lang.String,java.lang.Long> |
deviceRegMap |
protected java.util.Map<java.lang.Long,cz.mallat.uasparser.OsEntry> |
osMap |
protected java.util.Map<java.lang.String,java.lang.Long> |
osRegMap |
protected java.util.Map<java.lang.String,cz.mallat.uasparser.RobotEntry> |
robotsMap |
protected UserAgentInfo |
unknownAgentInfo |
| Constructor and Description |
|---|
UASparser()
Create a new
UASparser without initializing maps. |
UASparser(java.io.InputStream inputStreamToDefinitionFile)
Use the given inputstream to load the definition file from the local filesystem
|
UASparser(java.lang.String localDefinitionFilename)
Use the given filename to load the definition file from the local filesystem
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkDataMaps()
Deprecated.
|
protected java.lang.String |
convertPerlToJavaRegex(java.lang.String regex)
Converts a PERL style regex into the Java style.
|
protected void |
createInternalDataStructure(java.util.List<Section> sectionList)
Creates the internal data structures from the sectionList
|
protected void |
guessDeviceType(UserAgentInfo uaInfo)
Determine device type based on UA type field
|
protected void |
loadDataFromFile(java.io.File definitionFile)
loads the data file and creates all internal data structures
|
protected void |
loadDataFromFile(java.io.InputStream is)
loads the data file and creates all internal data structs
|
UserAgentInfo |
parse(java.lang.String useragent)
Parse the given user agent string and returns a UserAgentInfo object with the related data
|
UserAgentInfo |
parseBrowserOnly(java.lang.String useragent)
Parse the given user agent string and returns a UserAgentInfo object
with only the related Browser data set.
|
protected void |
preCompileBrowserRegMap()
Precompile browser regexes
|
protected void |
preCompileDeviceRegMap()
Precompile device regexes
|
protected void |
preCompileOsRegMap()
Precompile OS regexes
|
protected void |
preCompileRegExes()
Precompile all regular regexes
|
protected void |
processBrowserRegex(java.lang.String useragent,
UserAgentInfo uaInfo)
Searchs in the browser regex table.
|
protected void |
processDeviceRegex(java.lang.String useragent,
UserAgentInfo uaInfo)
Searches in the devices regex table.
|
protected void |
processOsRegex(java.lang.String useragent,
UserAgentInfo uaInfo)
Searches in the os regex table.
|
protected boolean |
processRobot(java.lang.String useragent,
UserAgentInfo uaInfo)
Checks if the User Agent matches that of a known Robot (crawler or other automated agent)
|
protected java.util.Map<java.lang.String,cz.mallat.uasparser.RobotEntry> robotsMap
protected java.util.Map<java.lang.Long,cz.mallat.uasparser.OsEntry> osMap
protected java.util.Map<java.lang.Long,cz.mallat.uasparser.BrowserEntry> browserMap
protected java.util.Map<java.lang.Long,java.lang.String> browserTypeMap
protected java.util.Map<java.lang.String,java.lang.Long> browserRegMap
protected java.util.Map<java.lang.Long,java.lang.Long> browserOsMap
protected java.util.Map<java.lang.String,java.lang.Long> osRegMap
protected java.util.Map<java.lang.Long,cz.mallat.uasparser.DeviceEntry> deviceMap
protected java.util.Map<java.lang.String,java.lang.Long> deviceRegMap
protected java.util.Map<jregex.Pattern,java.lang.Long> compiledBrowserRegMap
protected java.util.Map<jregex.Pattern,java.lang.Long> compiledOsRegMap
protected java.util.Map<jregex.Pattern,java.lang.Long> compiledDeviceRegMap
protected UserAgentInfo unknownAgentInfo
public UASparser()
UASparser without initializing maps. Expects an updater to be
configured and run immediately.public UASparser(java.lang.String localDefinitionFilename)
throws java.io.IOException
localDefinitionFilename - java.io.IOExceptionpublic UASparser(java.io.InputStream inputStreamToDefinitionFile)
throws java.io.IOException
inputStreamToDefinitionFile - java.io.IOException@Deprecated
protected void checkDataMaps()
throws java.io.IOException
java.io.IOExceptionpublic UserAgentInfo parse(java.lang.String useragent) throws java.io.IOException
useragent - java.io.IOException - may happen when the retrieval of the data file failsprotected void guessDeviceType(UserAgentInfo uaInfo)
uaInfo - public UserAgentInfo parseBrowserOnly(java.lang.String useragent)
useragent - UserAgentInfoprotected void preCompileRegExes()
protected void preCompileBrowserRegMap()
protected void preCompileOsRegMap()
protected void preCompileDeviceRegMap()
protected boolean processRobot(java.lang.String useragent,
UserAgentInfo uaInfo)
useragent - uaInfo - protected void processBrowserRegex(java.lang.String useragent,
UserAgentInfo uaInfo)
useragent - uaInfo - protected void processOsRegex(java.lang.String useragent,
UserAgentInfo uaInfo)
useragent - uaInfo - protected void processDeviceRegex(java.lang.String useragent,
UserAgentInfo uaInfo)
useragent - uaInfo - protected void loadDataFromFile(java.io.File definitionFile)
throws java.io.IOException
definitionFile - java.io.IOExceptionprotected void loadDataFromFile(java.io.InputStream is)
throws java.io.IOException
is - java.io.IOExceptionprotected void createInternalDataStructure(java.util.List<Section> sectionList)
sectionList - protected java.lang.String convertPerlToJavaRegex(java.lang.String regex)
regex -