@Test public void parseOperatingSystemVersion_differentFamilies() { final String bada = "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S7230E/S723EXXJJ3; U; Bada/1.0; nl-nl) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.0 Mobile WQVGA SMM-MMS/1.2.0 OPN-B"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.BADA, bada).toVersionString()).isEqualTo("1.0"); final String freebsd = "Opera/9.80 (X11; FreeBSD 8.2-STABLE amd64; U; en) Presto/2.9.168 Version/11.52"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.BSD, freebsd).toVersionString()).isEqualTo("8.2-STABLE"); final String ipad = "Mozilla/5.0 (iPad; U; CPU OS 5_1 like Mac OS X; en_us) AppleWebKit/6534.46 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.IOS, ipad).toVersionString()).isEqualTo("5.1"); final String jvm = "Java/1.7.0_04-ea"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.JVM, jvm).toVersionString()).isEqualTo("1.7.0_04-ea"); final String macosx = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.OS_X, macosx).toVersionString()).isEqualTo("10.7.3"); final String symbian = "SonyEricssonU1i/R1BB; Mozilla/5.0 (SymbianOS/9.4; U; Series60/5.0 Profile/MIDP-2.1 Configuration/CLDC-1.1 model-orange) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 Safari/525"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.SYMBIAN, symbian).toVersionString()).isEqualTo("9.4"); final String webos = "Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.5; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.WEBOS, webos).toVersionString()).isEqualTo("3.0.5"); final String windows8 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"; assertThat(VersionParser.parseOperatingSystemVersion(OperatingSystemFamily.WINDOWS, windows8).toVersionString()).isEqualTo("6.2"); }
public static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent) { Check.notNull(family, "family"); Check.notNull(userAgent, "userAgent"); final VersionNumber v; if (OperatingSystemFamily.ANDROID == family) { v = identifyAndroidVersion(userAgent); } else if (OperatingSystemFamily.BADA == family) { v = identifyBadaVersion(userAgent); } else if (OperatingSystemFamily.BSD == family) { v = identifyBSDVersion(userAgent); } else if (OperatingSystemFamily.IOS == family) { v = identifyIOSVersion(userAgent); } else if (OperatingSystemFamily.JVM == family) { v = identifyJavaVersion(userAgent); } else if (OperatingSystemFamily.OS_X == family) { v = identifyOSXVersion(userAgent); } else if (OperatingSystemFamily.SYMBIAN == family) { v = identifySymbianVersion(userAgent); } else if (OperatingSystemFamily.WEBOS == family) { v = identifyWebOSVersion(userAgent); } else if (OperatingSystemFamily.WINDOWS == family) { v = identifyWindowsVersion(userAgent); } else { v = VersionNumber.UNKNOWN; } return v; }
VersionParser { public static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent) { Check.notNull(family, "family"); Check.notNull(userAgent, "userAgent"); final VersionNumber v; if (OperatingSystemFamily.ANDROID == family) { v = identifyAndroidVersion(userAgent); } else if (OperatingSystemFamily.BADA == family) { v = identifyBadaVersion(userAgent); } else if (OperatingSystemFamily.BSD == family) { v = identifyBSDVersion(userAgent); } else if (OperatingSystemFamily.IOS == family) { v = identifyIOSVersion(userAgent); } else if (OperatingSystemFamily.JVM == family) { v = identifyJavaVersion(userAgent); } else if (OperatingSystemFamily.OS_X == family) { v = identifyOSXVersion(userAgent); } else if (OperatingSystemFamily.SYMBIAN == family) { v = identifySymbianVersion(userAgent); } else if (OperatingSystemFamily.WEBOS == family) { v = identifyWebOSVersion(userAgent); } else if (OperatingSystemFamily.WINDOWS == family) { v = identifyWindowsVersion(userAgent); } else { v = VersionNumber.UNKNOWN; } return v; } }
VersionParser { public static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent) { Check.notNull(family, "family"); Check.notNull(userAgent, "userAgent"); final VersionNumber v; if (OperatingSystemFamily.ANDROID == family) { v = identifyAndroidVersion(userAgent); } else if (OperatingSystemFamily.BADA == family) { v = identifyBadaVersion(userAgent); } else if (OperatingSystemFamily.BSD == family) { v = identifyBSDVersion(userAgent); } else if (OperatingSystemFamily.IOS == family) { v = identifyIOSVersion(userAgent); } else if (OperatingSystemFamily.JVM == family) { v = identifyJavaVersion(userAgent); } else if (OperatingSystemFamily.OS_X == family) { v = identifyOSXVersion(userAgent); } else if (OperatingSystemFamily.SYMBIAN == family) { v = identifySymbianVersion(userAgent); } else if (OperatingSystemFamily.WEBOS == family) { v = identifyWebOSVersion(userAgent); } else if (OperatingSystemFamily.WINDOWS == family) { v = identifyWindowsVersion(userAgent); } else { v = VersionNumber.UNKNOWN; } return v; } private  VersionParser(); }
VersionParser { public static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent) { Check.notNull(family, "family"); Check.notNull(userAgent, "userAgent"); final VersionNumber v; if (OperatingSystemFamily.ANDROID == family) { v = identifyAndroidVersion(userAgent); } else if (OperatingSystemFamily.BADA == family) { v = identifyBadaVersion(userAgent); } else if (OperatingSystemFamily.BSD == family) { v = identifyBSDVersion(userAgent); } else if (OperatingSystemFamily.IOS == family) { v = identifyIOSVersion(userAgent); } else if (OperatingSystemFamily.JVM == family) { v = identifyJavaVersion(userAgent); } else if (OperatingSystemFamily.OS_X == family) { v = identifyOSXVersion(userAgent); } else if (OperatingSystemFamily.SYMBIAN == family) { v = identifySymbianVersion(userAgent); } else if (OperatingSystemFamily.WEBOS == family) { v = identifyWebOSVersion(userAgent); } else if (OperatingSystemFamily.WINDOWS == family) { v = identifyWindowsVersion(userAgent); } else { v = VersionNumber.UNKNOWN; } return v; } private  VersionParser(); static VersionNumber parseLastVersionNumber(@Nonnull final String text); static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent); static VersionNumber parseVersion(@Nonnull final String version); }
VersionParser { public static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent) { Check.notNull(family, "family"); Check.notNull(userAgent, "userAgent"); final VersionNumber v; if (OperatingSystemFamily.ANDROID == family) { v = identifyAndroidVersion(userAgent); } else if (OperatingSystemFamily.BADA == family) { v = identifyBadaVersion(userAgent); } else if (OperatingSystemFamily.BSD == family) { v = identifyBSDVersion(userAgent); } else if (OperatingSystemFamily.IOS == family) { v = identifyIOSVersion(userAgent); } else if (OperatingSystemFamily.JVM == family) { v = identifyJavaVersion(userAgent); } else if (OperatingSystemFamily.OS_X == family) { v = identifyOSXVersion(userAgent); } else if (OperatingSystemFamily.SYMBIAN == family) { v = identifySymbianVersion(userAgent); } else if (OperatingSystemFamily.WEBOS == family) { v = identifyWebOSVersion(userAgent); } else if (OperatingSystemFamily.WINDOWS == family) { v = identifyWindowsVersion(userAgent); } else { v = VersionNumber.UNKNOWN; } return v; } private  VersionParser(); static VersionNumber parseLastVersionNumber(@Nonnull final String text); static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent); static VersionNumber parseVersion(@Nonnull final String version);  }