Scans the jar and filters all elements

@param u
the uri of the jar file to be scanned
@param pathPredicate
the matching predicate for collecting the entries

@return a stream of collected strings
556456
private Collection<String> scanJar(URI u, Predicate<Path> pathPredicate) {
        try (FileSystem fs = FileSystems.newFileSystem(u, READY_ONLY_ENV)) {
            return Files.walk(fs.getPath("/"))
                        .filter(pathPredicate)
                        .map(f -> toFQName(f.toAbsolutePath()))
                        .distinct()
                        .collect(Collectors.toList());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
1252109
public Stream<URL> getResources(String path) {
        Enumeration<URL> all;
        try {
            all = classLoader.getResources(prefixPath(path));
        } catch (IOException e) {
            return Stream.empty();
        }
        Stream.Builder<URL> builder = Stream.builder();
        while (all.hasMoreElements()) {
            URL url = all.nextElement();
            builder.accept(url);
        }
        return builder.build();
    }
1771
public Optional<T> filter(final Predicate<? super T> predicate) {
        if (isPresent() && predicate.test(get())) {
            return this;
        }

        return empty();
    }
621923
private boolean filter(final String classpathElementPath) {
        if (scanSpec.classpathElementFilters != null) {
            for (final ClasspathElementFilter filter : scanSpec.classpathElementFilters) {
                if (!filter.includeClasspathElement(classpathElementPath)) {
                    return false;
                }
            }
        }
        return true;
    }
854646
@CheckReturnValue
  public ScannerSupplier filter(Predicate<? super BugCheckerInfo> predicate) {
    ImmutableSet.Builder<String> disabled = ImmutableSet.builder();
    for (BugCheckerInfo check : getAllChecks().values()) {
      if (!predicate.apply(check)) {
        disabled.add(check.canonicalName());
      }
    }
    return new ScannerSupplierImpl(getAllChecks(), severities(), disabled.build(), getFlags());
  }
693329
public List<String> ls(String path, final Filter<LsEntry> filter) {
		final List<String> fileNames = new ArrayList<>();
		try {
			channel.ls(path, new LsEntrySelector() {
				@Override
				public int select(LsEntry entry) {
					String fileName = entry.getFilename();
					if (false == StrUtil.equals(".", fileName) && false == StrUtil.equals("..", fileName)) {
						if (null == filter || filter.accept(entry)) {
							fileNames.add(entry.getFilename());
						}
					}
					return CONTINUE;
				}
			});
		} catch (SftpException e) {
			throw new JschRuntimeException(e);
		}
		return fileNames;
	}
971143
public Collection<RepositoryResource> getMatchingResources(final FilterPredicate... predicates) throws RepositoryBackendException {
        Collection<RepositoryResource> resources = cycleThroughRepositories(new RepositoryInvoker<RepositoryResource>() {
            @Override
            public Collection<RepositoryResource> performActionOnRepository(RepositoryConnection connection) throws RepositoryBackendException {
                return connection.getMatchingResources(predicates);
            }
        });
        return resources;
    }
1018335
public ResourceIterator getResourceIterator(URL url, Filter filter)
    {
        String urlString = url.toString();
        try
        {
            if (urlString.endsWith("!/"))
            {
                urlString = urlString.substring(4);
                urlString = urlString.substring(0, urlString.length() - 2);
                url = new URL(urlString);
            }

            if (urlString.endsWith(".class"))
            {
                File f = new File(url.getPath());
                return new ClassFileIterator(f);
            }
            else if (!urlString.endsWith("/"))
            {
                return new JarFileIterator(url.openStream(), filter);
            }
            else
            {
                if (!url.getProtocol().equals("file"))
                {
                    throw new ResourceReadingException("Unable to understand protocol: " + url.getProtocol());
                }

                File f = new File(url.getPath());
                if (f.isDirectory() || url.getProtocol().toUpperCase().equals(AllowedProtocol.VFS.name()))
                {
                    return new ClassFileIterator(f, filter);
                }
                else
                {
                    return new JarFileIterator(url.openStream(), filter);
                }
            }
        }
        catch (MalformedURLException e)
        {
            throw new ResourceReadingException(e);
        }
        catch (IOException e)
        {
            throw new ResourceReadingException(e);
        }
    }
217773
@Nullable
  public static String getFileNameFromUri(URI uri) {
    if (!uri.getScheme().equals("jar")) {
      return uri.getPath();
    }

    try {
      String jarEntryFileName = ((JarURLConnection) uri.toURL().openConnection()).getEntryName();
      // It's possible (though it violates the zip file spec) for paths to zip file entries to use
      // '\' as the separator. Normalize to use '/'.
      jarEntryFileName = BACKSLASH_MATCHER.replaceFrom(jarEntryFileName, '/');
      if (!jarEntryFileName.startsWith("/")) {
        jarEntryFileName = "/" + jarEntryFileName;
      }
      return jarEntryFileName;
    } catch (IOException e) {
      return null;
    }
  }
1213793
public static List<File> classpathFiles(final Predicate<File> predicate) {
        return pathsFiles(System.getProperty("java.class.path"), predicate);

    }
786766
public List<String> findAllStrings(String uri) throws IOException {
        String fulluri = path + uri;

        List<String> strings = new ArrayList<>();

        Enumeration<URL> resources = getResources(fulluri);
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            String string = readContents(url);
            strings.add(string);
        }
        return strings;
    }
116723
public String getObjectsAsString(final Graph graph,
            final Node subject, final Resource predicate, final boolean uriAsLink) {
        LOGGER.trace("Getting Objects as String: s:{}, p:{}, g:{}", subject, predicate, graph);
        final Iterator<Node> iterator = listObjects(graph, subject, predicate.asNode());
        if (iterator.hasNext()) {
            final Node obj = iterator.next();
            if (obj.isLiteral()) {
                final String lit = obj.getLiteralValue().toString();
                return lit.isEmpty() ? "<empty>" : lit;
            }
            return uriAsLink ? "&lt;<a href=\"" + obj.getURI() + "\">" + obj.getURI() + "</a>&gt;" : obj.getURI();
        }
        return "";
    }
845092
public static <T> com.google.common.base.Predicate<T> wrap(Predicate predicate) {
        Path<?> path = predicate.accept(PathExtractor.DEFAULT, null);
        if (path != null) {
            final Evaluator<Boolean> ev = createEvaluator(path.getRoot(), predicate);
            return new com.google.common.base.Predicate<T>() {
                @Override
                public boolean apply(T input) {
                    return ev.evaluate(input);
                }
            };
        } else {
            throw new IllegalArgumentException("No path in " + predicate);
        }
    }
1136058
public final predicate_return predicate() throws RecognitionException {
        predicate_return retval = new predicate_return();
        retval.start = input.LT(1);


        CommonTree root_0 = null;

        Token char_literal7=null;
        Token char_literal9=null;
        Token TRUE16=null;
        Token FALSE17=null;
        filter_return filter8 =null;

        comparison_function_return comparison_function10 =null;

        between_predicate_return between_predicate11 =null;

        in_predicate_return in_predicate12 =null;

        null_predicate_return null_predicate13 =null;

        regex_predicate_return regex_predicate14 =null;

        exists_predicate_return exists_predicate15 =null;


        CommonTree char_literal7_tree=null;
        CommonTree char_literal9_tree=null;
        CommonTree TRUE16_tree=null;
        CommonTree FALSE17_tree=null;
        RewriteRuleTokenStream stream_FALSE=new RewriteRuleTokenStream(adaptor,"token FALSE");
        RewriteRuleTokenStream stream_TRUE=new RewriteRuleTokenStream(adaptor,"token TRUE");
        RewriteRuleTokenStream stream_33=new RewriteRuleTokenStream(adaptor,"token 33");
        RewriteRuleTokenStream stream_34=new RewriteRuleTokenStream(adaptor,"token 34");
        RewriteRuleSubtreeStream stream_filter=new RewriteRuleSubtreeStream(adaptor,"rule filter");
        try {
            // MessageFilter.g:117:2: ( '(' filter ')' -> filter | comparison_function | between_predicate | in_predicate | null_predicate | regex_predicate | exists_predicate | TRUE -> TRUE | FALSE -> FALSE )
            int alt5=9;
            switch ( input.LA(1) ) {
            case 33:
                {
                alt5=1;
                }
                break;
            case XPATH_FUN_NAME:
                {
                int LA5_2 = input.LA(2);

                if ( (LA5_2==33) ) {
                    int LA5_6 = input.LA(3);

                    if ( (LA5_6==STRING) ) {
                        int LA5_7 = input.LA(4);

                        if ( (LA5_7==34) ) {
                            switch ( input.LA(5) ) {
                            case EQUALS:
                            case GE:
                            case GT:
                            case LE:
                            case LT:
                            case NOT_EQUALS:
                                {
                                alt5=2;
                                }
                                break;
                            case BETWEEN:
                                {
                                alt5=3;
                                }
                                break;
                            case IN:
                                {
                                alt5=4;
                                }
                                break;
                            case IS:
                                {
                                alt5=5;
                                }
                                break;
                            case MATCHES:
                                {
                                alt5=6;
                                }
                                break;
                            case EXISTS:
                                {
                                alt5=7;
                                }
                                break;
                            default:
                                NoViableAltException nvae =
                                    new NoViableAltException("", 5, 8, input);

                                throw nvae;

                            }

                        }
                        else {
                            NoViableAltException nvae =
                                new NoViableAltException("", 5, 7, input);

                            throw nvae;

                        }
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 5, 6, input);

                        throw nvae;

                    }
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 5, 2, input);

                    throw nvae;

                }
                }
                break;
            case EXISTS:
                {
                alt5=7;
                }
                break;
            case TRUE:
                {
                alt5=8;
                }
                break;
            case FALSE:
                {
                alt5=9;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 5, 0, input);

                throw nvae;

            }

            switch (alt5) {
                case 1 :
                    // MessageFilter.g:117:4: '(' filter ')'
                    {
                    char_literal7=(Token)match(input,33,FOLLOW_33_in_predicate448);
                    stream_33.add(char_literal7);


                    pushFollow(FOLLOW_filter_in_predicate450);
                    filter8=filter();

                    state._fsp--;

                    stream_filter.add(filter8.getTree());

                    char_literal9=(Token)match(input,34,FOLLOW_34_in_predicate452);
                    stream_34.add(char_literal9);


                    // AST REWRITE
                    // elements: filter
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 117:19: -> filter
                    {
                        adaptor.addChild(root_0, stream_filter.nextTree());

                    }


                    retval.tree = root_0;

                    }
                    break;
                case 2 :
                    // MessageFilter.g:118:3: comparison_function
                    {
                    root_0 = (CommonTree)adaptor.nil();


                    pushFollow(FOLLOW_comparison_function_in_predicate463);
                    comparison_function10=comparison_function();

                    state._fsp--;

                    adaptor.addChild(root_0, comparison_function10.getTree());

                    }
                    break;
                case 3 :
                    // MessageFilter.g:119:3: between_predicate
                    {
                    root_0 = (CommonTree)adaptor.nil();


                    pushFollow(FOLLOW_between_predicate_in_predicate469);
                    between_predicate11=between_predicate();

                    state._fsp--;

                    adaptor.addChild(root_0, between_predicate11.getTree());

                    }
                    break;
                case 4 :
                    // MessageFilter.g:120:3: in_predicate
                    {
                    root_0 = (CommonTree)adaptor.nil();


                    pushFollow(FOLLOW_in_predicate_in_predicate475);
                    in_predicate12=in_predicate();

                    state._fsp--;

                    adaptor.addChild(root_0, in_predicate12.getTree());

                    }
                    break;
                case 5 :
                    // MessageFilter.g:121:3: null_predicate
                    {
                    root_0 = (CommonTree)adaptor.nil();


                    pushFollow(FOLLOW_null_predicate_in_predicate481);
                    null_predicate13=null_predicate();

                    state._fsp--;

                    adaptor.addChild(root_0, null_predicate13.getTree());

                    }
                    break;
                case 6 :
                    // MessageFilter.g:122:3: regex_predicate
                    {
                    root_0 = (CommonTree)adaptor.nil();


                    pushFollow(FOLLOW_regex_predicate_in_predicate487);
                    regex_predicate14=regex_predicate();

                    state._fsp--;

                    adaptor.addChild(root_0, regex_predicate14.getTree());

                    }
                    break;
                case 7 :
                    // MessageFilter.g:123:3: exists_predicate
                    {
                    root_0 = (CommonTree)adaptor.nil();


                    pushFollow(FOLLOW_exists_predicate_in_predicate493);
                    exists_predicate15=exists_predicate();

                    state._fsp--;

                    adaptor.addChild(root_0, exists_predicate15.getTree());

                    }
                    break;
                case 8 :
                    // MessageFilter.g:124:3: TRUE
                    {
                    TRUE16=(Token)match(input,TRUE,FOLLOW_TRUE_in_predicate499);
                    stream_TRUE.add(TRUE16);


                    // AST REWRITE
                    // elements: TRUE
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 124:8: -> TRUE
                    {
                        adaptor.addChild(root_0,
                        new TrueValueTreeNode(stream_TRUE.nextToken())
                        );

                    }


                    retval.tree = root_0;

                    }
                    break;
                case 9 :
                    // MessageFilter.g:125:3: FALSE
                    {
                    FALSE17=(Token)match(input,FALSE,FOLLOW_FALSE_in_predicate511);
                    stream_FALSE.add(FALSE17);


                    // AST REWRITE
                    // elements: FALSE
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 125:9: -> FALSE
                    {
                        adaptor.addChild(root_0,
                        new FalseValueTreeNode(stream_FALSE.nextToken())
                        );

                    }


                    retval.tree = root_0;

                    }
                    break;

            }
            retval.stop = input.LT(-1);


            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
1030959
public static <K, V> Stream<Entry<K, V>> getEntryStreamWithFilter(
            Map<K, V> map, Predicate<? super Entry<K, V>> predicate) {
        return buildEntryStream(map).filter(predicate);
    }
302913
public static boolean apply(final char[][] robotsFilter, final URI url) {
		if (robotsFilter.length == 0) return true;
		final String pathQuery = BURL.pathAndQuery(url);
		int from = 0;
		int to = robotsFilter.length - 1;
		while (from <= to) {
			final int mid = (from + to) >>> 1;
			final int cmp = compare(robotsFilter[mid], pathQuery);
			if (cmp < 0) from = mid + 1;
			else if (cmp > 0) to = mid - 1;
			else return false; // key found (unlikely, but possible)
		}
		return from == 0 ? true : doesNotStartsWith(pathQuery, robotsFilter[from - 1]);
	}
784314
public static List<Path> getSubPathList(Path startDirectoryPath,
			Predicate<Path> filter) {
		return getSubPathList(startDirectoryPath, Integer.MAX_VALUE, filter);
	}