public boolean accept(String name) { for (Filter filter : filters) { if (filter.accept(name)) return true; } return false; }
private DirFilter getDirFilter() { DirFilter deepestDirFilter = new DirFilter(Operator.EQ, preferences.get(Keys.MEDIA_DIR)); for (Filter<? super Tables.Tracks> filter : getFilters()) { final DirFilter finalDeepestDirFilter = deepestDirFilter; deepestDirFilter = filter.accept( new TurtleFilterVisitor<Tables.Tracks, DirFilter>() { public DirFilter visit(DirFilter dirFilter) { return finalDeepestDirFilter .getValue() .contains(dirFilter.getValueWithoutWildcards()) ? finalDeepestDirFilter : new DirFilter(Operator.EQ, dirFilter.getValueWithoutWildcards()); } public DirFilter visit(NotFilter<? super Tables.Tracks> notFilter) { return finalDeepestDirFilter; } public <T, Z> DirFilter visit( FieldFilter<? super Tables.Tracks, Z, T> fieldFilter) { return finalDeepestDirFilter; } public DirFilter visit(FilterSet<? super Tables.Tracks> filterSet) { return finalDeepestDirFilter; } }); } return deepestDirFilter; }
private static void populateClasses( final Shell shell, final IParent parent, final List<IType> types, final Filter filter) { try { for (final IJavaElement element : parent.getChildren()) { if (element instanceof IType) { final IType type = (IType) element; if (type.isClass() && type.isStructureKnown() && !type.isAnonymous() && !type.isLocal() && !Flags.isAbstract(type.getFlags()) && Flags.isPublic(type.getFlags()) && (filter == null || filter.accept(type))) { types.add(type); } } else if (element instanceof IParent && !element.getPath().toString().contains("/test/") && (!(element instanceof IPackageFragmentRoot) || !((IPackageFragmentRoot) element).isExternal())) { populateClasses(shell, (IParent) element, types, filter); } } } catch (final JavaModelException e) { Activator.error(e); } }
public ResourceEntry[] getChildren(Filter filter) { ResourceEntry[] children = getChildren(); List childrenFiltered = new ArrayList(); for (int i = 0; i < children.length; i++) { if (filter.accept(children[i])) childrenFiltered.add(children[i]); } return (ResourceEntry[]) childrenFiltered.toArray(new ResourceEntry[childrenFiltered.size()]); }
@Override public boolean accept(Artifact artifact) { for (Filter filter : filters) { if (filter.accept(artifact)) { return result(true, artifact.toString()); } } return result(false, artifact.toString()); }
private static List<Integer> copyFiltered(List<Integer> list, Filter<Integer> filter) { List<Integer> result = new ArrayList<Integer>(); for (Integer i : list) { if (filter.accept(i)) { result.add(i); } } return result; }
@Override protected void doRun(RunNotifier notifier) { try { myIgnoringFilter.accept(myRequest); myRequest.getRunner().run(notifier); } catch (Filter.FilterException e) { ignoreRequest(notifier, e); } }
/** * Gets a friend based on a given filter. * * @param filter The filter defines conditions that your Friend must meet. * @return The first Friend that meets the conditions or null if not found. */ public Friend getFriend(Filter<Friend> filter) { for (final RosterEntry e : connection.getRoster().getEntries()) { final Friend f = new Friend(this, connection, e); if (filter.accept(f)) { return f; } } return null; }
@Override public boolean accept(DependencyNode node, List<DependencyNode> parents) { AntClient.getInstance().log("Filtering - " + super.toString() + "...", Project.MSG_DEBUG); for (Filter filter : filters) { if (filter.accept(node, parents)) { return result(true, node.toString()); } } return result(false, node.toString()); }
/** * Gets a list of your friends based on a given filter. * * @param filter The filter defines conditions that your Friends must meet. * @return A List of your Friends that meet the condition of your Filter */ public List<Friend> getFriends(Filter<Friend> filter) { final ArrayList<Friend> friends = new ArrayList<>(); for (final RosterEntry e : connection.getRoster().getEntries()) { final Friend f = new Friend(this, connection, e); if (filter.accept(f)) { friends.add(f); } } return friends; }
XmlNode[] getMatchingChildren(Filter filter) { ArrayList rv = new ArrayList(); NodeList nodes = this.dom.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (filter.accept(node)) { rv.add(createImpl(node)); } } return (XmlNode[]) rv.toArray(new XmlNode[0]); }
protected void packBundle(ZipOutputStream output, Bundle bundle, String path, Filter filter) throws IOException { if (filter != null && !filter.accept(path)) { log(Level.FINE, "exclude {0}/{1}", new Object[] {bundle.getBundleID(), path}); return; } BundleFile bundleFile = bundle.getBundleFile(); if (bundleFile.isDirectory(path)) { List<String> entries = bundleFile.getEntryPaths(path); for (String entry : entries) { packBundle(output, bundle, entry, filter); } return; } // pack the JAR/ZIP BundleEntry bundleEntry = bundleFile.getEntry(path); if (path.endsWith(".jar") || path.endsWith(".zip")) { File tempZipFile = createTempFile(bundleEntry); try { ZipFile zipFile = new ZipFile(tempZipFile); try { packZip(output, bundleEntry, zipFile, filter); } finally { zipFile.close(); } } finally { tempZipFile.delete(); } return; } // pack the normal entry if (existingEntries.contains(path)) { log(Level.WARNING, "duplicate {0}/{1}", new Object[] {bundle.getBundleID(), path}); return; } existingEntries.add(path); InputStream input = bundleEntry.getInputStream(); try { ZipEntry zipEntry = new ZipEntry(bundleEntry.getName()); zipEntry.setTime(bundleEntry.getTime()); zipEntry.setSize(bundleEntry.getSize()); output.putNextEntry(zipEntry); try { copyStream(input, output); } finally { output.closeEntry(); } } finally { input.close(); } }
@Override public final void visit(Set<Instance> resultSet, Filter filter) { if (resultSet.contains(this)) { return; } if (filter != null) { if (filter.accept(this)) { resultSet.add(this); } } else { resultSet.add(this); } State state = mHeap.mState; ClassObj isa = state.findClass(mClassId); int[] types = isa.mFieldTypes; ByteArrayInputStream bais = new ByteArrayInputStream(mFieldValues); DataInputStream dis = new DataInputStream(bais); final int N = types.length; /* * Spin through the list of fields, find all object references, * and list ourselves as a reference holder. */ try { for (int i = 0; i < N; i++) { int type = types[i]; int size = Types.getTypeSize(type); if (type == Types.OBJECT) { long id; if (size == 4) { id = dis.readInt(); } else { id = dis.readLong(); } Instance instance = state.findReference(id); if (instance != null) { instance.visit(resultSet, filter); } } else { dis.skipBytes(size); } } } catch (Exception e) { e.printStackTrace(); } }
private Result doFakeAuthorization(PaymentDTOEx payment, String transactionId) throws PluggableTaskException { CreditCardDTO creditCard = payment.getCreditCard(); if (creditCard == null || !myFilter.accept(creditCard)) { // give real processors a chance return new Result(null, true); } Integer resultId = getProcessResultId(creditCard); payment.setPaymentResult(new PaymentResultDAS().find(resultId)); PaymentAuthorizationDTO authInfo = createAuthorizationDTO(resultId, transactionId); storeProcessedAuthorization(payment, authInfo); boolean wasProcessed = (Constants.RESULT_FAIL.equals(resultId) || Constants.RESULT_OK.equals(resultId)); boolean shouldCallOthers = !wasProcessed && !myShouldBlockOtherProcessors; return new Result(authInfo, shouldCallOthers); }
protected void packZip( ZipOutputStream output, BundleEntry bundleEntry, ZipFile zipFile, Filter filter) throws IOException { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry srcEntry = entries.nextElement(); String entryName = srcEntry.getName(); if (filter != null && !filter.accept(bundleEntry.getName() + "/" + entryName)) { log( Level.FINE, "exclude {0}/{1}/{2}", new Object[] {bundleEntry.getBundleID(), bundleEntry.getName(), entryName}); continue; } if (entryName.endsWith("/")) { continue; } if (existingEntries.contains(entryName)) { log( Level.WARNING, "duplicate {0}/{1}/{2}", new Object[] {bundleEntry.getBundleID(), bundleEntry.getName(), entryName}); continue; } existingEntries.add(entryName); ZipEntry tgtEntry = new ZipEntry(entryName); tgtEntry.setTime(srcEntry.getTime()); output.putNextEntry(tgtEntry); try { InputStream input = zipFile.getInputStream(srcEntry); try { copyStream(input, output); } finally { input.close(); } } finally { output.closeEntry(); } } }