@Test public void dynamicFilter() throws IOException { ArrayList<Signature> signatures; int signaturesOriginal = df.signatures.size(); signatures = df.filterBy("IsMobile", "True", null); int signaturesIsMobile = signatures.size(); signatures = df.filterBy("PlatformName", "Android", signatures); int signaturesPlatformname = signatures.size(); signatures = df.filterBy("BrowserName", "Chrome", signatures); int signaturesBrowserName = signatures.size(); assertTrue(signaturesOriginal >= signaturesIsMobile); assertTrue(signaturesIsMobile >= signaturesPlatformname); assertTrue(signaturesPlatformname >= signaturesBrowserName); for (Signature sig : signatures) { assertTrue(sig.getDeviceId() != null); } }
public ArrayList<Signature> filterBy(String propertyName, String propertyValue, ArrayList<Signature> listToFilter) throws IOException { if (propertyName.isEmpty() || propertyValue.isEmpty()) { throw new IllegalArgumentException("Property and Value can not be " + "empty or null."); } if (listToFilter == null) { listToFilter = signatures; } Property property = dataset.get(propertyName); if (property == null) { throw new IllegalArgumentException("Property you requested " + propertyName + " does not appear to exist in the current " + "data file."); } ArrayList<Signature> filterResults = new ArrayList<Signature>(); for (Signature sig : listToFilter) { Values vals = sig.getValues(property); if (vals.get(propertyValue) != null) { filterResults.add(sig); } } return filterResults; }
DynamicFilters { public ArrayList<Signature> filterBy(String propertyName, String propertyValue, ArrayList<Signature> listToFilter) throws IOException { if (propertyName.isEmpty() || propertyValue.isEmpty()) { throw new IllegalArgumentException("Property and Value can not be " + "empty or null."); } if (listToFilter == null) { listToFilter = signatures; } Property property = dataset.get(propertyName); if (property == null) { throw new IllegalArgumentException("Property you requested " + propertyName + " does not appear to exist in the current " + "data file."); } ArrayList<Signature> filterResults = new ArrayList<Signature>(); for (Signature sig : listToFilter) { Values vals = sig.getValues(property); if (vals.get(propertyValue) != null) { filterResults.add(sig); } } return filterResults; } }
DynamicFilters { public ArrayList<Signature> filterBy(String propertyName, String propertyValue, ArrayList<Signature> listToFilter) throws IOException { if (propertyName.isEmpty() || propertyValue.isEmpty()) { throw new IllegalArgumentException("Property and Value can not be " + "empty or null."); } if (listToFilter == null) { listToFilter = signatures; } Property property = dataset.get(propertyName); if (property == null) { throw new IllegalArgumentException("Property you requested " + propertyName + " does not appear to exist in the current " + "data file."); } ArrayList<Signature> filterResults = new ArrayList<Signature>(); for (Signature sig : listToFilter) { Values vals = sig.getValues(property); if (vals.get(propertyValue) != null) { filterResults.add(sig); } } return filterResults; } DynamicFilters(); }
DynamicFilters { public ArrayList<Signature> filterBy(String propertyName, String propertyValue, ArrayList<Signature> listToFilter) throws IOException { if (propertyName.isEmpty() || propertyValue.isEmpty()) { throw new IllegalArgumentException("Property and Value can not be " + "empty or null."); } if (listToFilter == null) { listToFilter = signatures; } Property property = dataset.get(propertyName); if (property == null) { throw new IllegalArgumentException("Property you requested " + propertyName + " does not appear to exist in the current " + "data file."); } ArrayList<Signature> filterResults = new ArrayList<Signature>(); for (Signature sig : listToFilter) { Values vals = sig.getValues(property); if (vals.get(propertyValue) != null) { filterResults.add(sig); } } return filterResults; } DynamicFilters(); static void main(String[] args); void run(); ArrayList<Signature> filterBy(String propertyName, 
                                         String propertyValue, 
                                         ArrayList<Signature> listToFilter); static ArrayList<E> iterableToArrayList(Iterable<E> iter); void close(); }
DynamicFilters { public ArrayList<Signature> filterBy(String propertyName, String propertyValue, ArrayList<Signature> listToFilter) throws IOException { if (propertyName.isEmpty() || propertyValue.isEmpty()) { throw new IllegalArgumentException("Property and Value can not be " + "empty or null."); } if (listToFilter == null) { listToFilter = signatures; } Property property = dataset.get(propertyName); if (property == null) { throw new IllegalArgumentException("Property you requested " + propertyName + " does not appear to exist in the current " + "data file."); } ArrayList<Signature> filterResults = new ArrayList<Signature>(); for (Signature sig : listToFilter) { Values vals = sig.getValues(property); if (vals.get(propertyValue) != null) { filterResults.add(sig); } } return filterResults; } DynamicFilters(); static void main(String[] args); void run(); ArrayList<Signature> filterBy(String propertyName, 
                                         String propertyValue, 
                                         ArrayList<Signature> listToFilter); static ArrayList<E> iterableToArrayList(Iterable<E> iter); void close();  }