@Test public void testAndroidWikimediaApp() throws IOException, ParseException{ UserAgentClassifier ua = new UserAgentClassifier(); Tuple input = tupleFactory.newTuple(1); input.set(0, "WikipediaMobile/1.3.4%20Mozilla/5.0%20(Linux;%20U;%20Android%204.0.3;%20en-us;%20PG86100%20Build/IML74K)%20AppleWebKit/534.30%20(KHTML,%20like%20Gecko)%20Version/4.0%20Mobile%20Safari/534.30"); Tuple output = ua.exec(input); assertEquals("Android", output.get(7)); input.set(0, "starts with something weird WikipediaMobile/1.3.4%20Mozilla/5.0%20(Linux;%20U;%20Android%204.0.3;%20en-us;%20PG86100%20Build/IML74K)%20AppleWebKit/534.30%20(KHTML,%20like%20Gecko)%20Version/4.0%20Mobile%20Safari/534.30"); output = ua.exec(input); assertEquals("Android", output.get(7)); }
@Override public final Tuple exec(final Tuple input) throws IOException { if (input == null || input.size() != 1 || input.get(0) == null) { return null; } UserAgent userAgent = new UserAgent(input.get(0).toString()); Tuple output = tupleFactory.newTuple(12); output.set(0, userAgent.getParentId()); output.set(1, userAgent.getModel()); output.set(2, userAgent.getDeviceOs()); output.set(3, userAgent.getDeviceOsVersion()); output.set(4, userAgent.getDeviceClass()); output.set(5, userAgent.getBrowser()); output.set(6, userAgent.getBrowserVersion()); output.set(7, userAgent.getWMFMobileApp()); output.set(8, userAgent.getAjaxSupportJavascript()); output.set(9, userAgent.getDisplayDimensions()); output.set(10, userAgent.getInputDevices()); output.set(11, userAgent.getNonWMFMobileApp()); return output; }
UserAgentClassifier extends EvalFunc<Tuple> { @Override public final Tuple exec(final Tuple input) throws IOException { if (input == null || input.size() != 1 || input.get(0) == null) { return null; } UserAgent userAgent = new UserAgent(input.get(0).toString()); Tuple output = tupleFactory.newTuple(12); output.set(0, userAgent.getParentId()); output.set(1, userAgent.getModel()); output.set(2, userAgent.getDeviceOs()); output.set(3, userAgent.getDeviceOsVersion()); output.set(4, userAgent.getDeviceClass()); output.set(5, userAgent.getBrowser()); output.set(6, userAgent.getBrowserVersion()); output.set(7, userAgent.getWMFMobileApp()); output.set(8, userAgent.getAjaxSupportJavascript()); output.set(9, userAgent.getDisplayDimensions()); output.set(10, userAgent.getInputDevices()); output.set(11, userAgent.getNonWMFMobileApp()); return output; } }
UserAgentClassifier extends EvalFunc<Tuple> { @Override public final Tuple exec(final Tuple input) throws IOException { if (input == null || input.size() != 1 || input.get(0) == null) { return null; } UserAgent userAgent = new UserAgent(input.get(0).toString()); Tuple output = tupleFactory.newTuple(12); output.set(0, userAgent.getParentId()); output.set(1, userAgent.getModel()); output.set(2, userAgent.getDeviceOs()); output.set(3, userAgent.getDeviceOsVersion()); output.set(4, userAgent.getDeviceClass()); output.set(5, userAgent.getBrowser()); output.set(6, userAgent.getBrowserVersion()); output.set(7, userAgent.getWMFMobileApp()); output.set(8, userAgent.getAjaxSupportJavascript()); output.set(9, userAgent.getDisplayDimensions()); output.set(10, userAgent.getInputDevices()); output.set(11, userAgent.getNonWMFMobileApp()); return output; } UserAgentClassifier(); }
UserAgentClassifier extends EvalFunc<Tuple> { @Override public final Tuple exec(final Tuple input) throws IOException { if (input == null || input.size() != 1 || input.get(0) == null) { return null; } UserAgent userAgent = new UserAgent(input.get(0).toString()); Tuple output = tupleFactory.newTuple(12); output.set(0, userAgent.getParentId()); output.set(1, userAgent.getModel()); output.set(2, userAgent.getDeviceOs()); output.set(3, userAgent.getDeviceOsVersion()); output.set(4, userAgent.getDeviceClass()); output.set(5, userAgent.getBrowser()); output.set(6, userAgent.getBrowserVersion()); output.set(7, userAgent.getWMFMobileApp()); output.set(8, userAgent.getAjaxSupportJavascript()); output.set(9, userAgent.getDisplayDimensions()); output.set(10, userAgent.getInputDevices()); output.set(11, userAgent.getNonWMFMobileApp()); return output; } UserAgentClassifier(); final Schema outputSchema(final Schema input); @Override final Tuple exec(final Tuple input); }
UserAgentClassifier extends EvalFunc<Tuple> { @Override public final Tuple exec(final Tuple input) throws IOException { if (input == null || input.size() != 1 || input.get(0) == null) { return null; } UserAgent userAgent = new UserAgent(input.get(0).toString()); Tuple output = tupleFactory.newTuple(12); output.set(0, userAgent.getParentId()); output.set(1, userAgent.getModel()); output.set(2, userAgent.getDeviceOs()); output.set(3, userAgent.getDeviceOsVersion()); output.set(4, userAgent.getDeviceClass()); output.set(5, userAgent.getBrowser()); output.set(6, userAgent.getBrowserVersion()); output.set(7, userAgent.getWMFMobileApp()); output.set(8, userAgent.getAjaxSupportJavascript()); output.set(9, userAgent.getDisplayDimensions()); output.set(10, userAgent.getInputDevices()); output.set(11, userAgent.getNonWMFMobileApp()); return output; } UserAgentClassifier(); final Schema outputSchema(final Schema input); @Override final Tuple exec(final Tuple input);  }