public static Browser parse ( final String agentString ) { if ( Strings . isEmpty ( agentString ) ) { return Browser . UNKNOWN ; } // first consider engine for ( Engine engine : Engine . values ( ) ) { String egineName = engine . name ; if ( agentString . contains ( egineName ) ) { for ( BrowserCategory category : engine . browserCategories ) { String version = category . match ( agentString ) ; if ( version != null ) { String key = category . getName ( ) + "/" + version ; Browser browser = browsers . get ( key ) ; if ( null == browser ) { browser = new Browser ( category , version ) ; browsers . put ( key , browser ) ; } return browser ; } } } } // for some usagent without suitable enginename; for ( BrowserCategory category : BrowserCategory . values ( ) ) { String version = category . match ( agentString ) ; if ( version != null ) { String key = category . getName ( ) + "/" + version ; Browser browser = browsers . get ( key ) ; if ( null == browser ) { browser = new Browser ( category , version ) ; browsers . put ( key , browser ) ; } return browser ; } } return Browser . UNKNOWN ; }
Iterates over all Browsers to compare the browser signature with the user agent string . If no match can be found Browser . UNKNOWN will be returned .