Subversion Repository Public Repository

litesoft

Diff Revisions 960 vs 961 for /trunk/DeviceDesktopTest/src/org/litesoft/useragent/UserAgentFormFactorDeterminerImpl.java

Diff revisions: vs.
  @@ -1,10 +1,8 @@
1 1 package org.litesoft.useragent;
2 2
3 - public class UserAgentFormFactorDeterminerImpl implements UserAgentFormFactorDeterminer
4 - {
3 + public class UserAgentFormFactorDeterminerImpl implements UserAgentFormFactorDeterminer {
5 4 @Override
6 - public UserAgentFormFactor determine( String pUserAgent )
7 - {
5 + public UserAgentFormFactor determine( String pUserAgent ) {
8 6 return ((pUserAgent.length() > 15) && containsAnyOf( pUserAgent,
9 7 "iPhone", "iPod", "Mobile", "Android", "iPad", "IEMobile", "Tablet",
10 8 "Kindle", "Silk",
  @@ -18,12 +16,9 @@
18 16 /**
19 17 * Look for the Find Words (where the Word may not start the User Agent).
20 18 */
21 - private boolean containsAnyOf( String pUserAgent, String... pFindWords )
22 - {
23 - for ( String zWord : pFindWords )
24 - {
25 - if ( containsWord( pUserAgent, zWord ) )
26 - {
19 + private boolean containsAnyOf( String pUserAgent, String... pFindWords ) {
20 + for ( String zWord : pFindWords ) {
21 + if ( containsWord( pUserAgent, zWord ) ) {
27 22 return true;
28 23 }
29 24 }
  @@ -33,21 +28,17 @@
33 28 /**
34 29 * Look for the Find Word (where the Word may not start the User Agent).
35 30 */
36 - private boolean containsWord( String pUserAgent, String pWord )
37 - {
38 - for ( int zAt, zFrom = 1; -1 != (zAt = pUserAgent.indexOf( pWord, zFrom )); )
39 - {
31 + private boolean containsWord( String pUserAgent, String pWord ) {
32 + for ( int zAt, zFrom = 1; -1 != (zAt = pUserAgent.indexOf( pWord, zFrom )); ) {
40 33 zFrom = zAt + pWord.length();
41 - if ( isWordSep( pUserAgent, zAt - 1 ) && isWordSep( pUserAgent, zFrom ) )
42 - {
34 + if ( isWordSep( pUserAgent, zAt - 1 ) && isWordSep( pUserAgent, zFrom ) ) {
43 35 return true;
44 36 }
45 37 }
46 38 return false;
47 39 }
48 40
49 - private boolean isWordSep( String pUserAgent, int pAt )
50 - {
41 + private boolean isWordSep( String pUserAgent, int pAt ) {
51 42 return (pAt == pUserAgent.length()) || !Character.isLetterOrDigit( pUserAgent.charAt( pAt ) );
52 43 }
53 44 }