Gets all URLs (resources) under the pattern.

@param locationPattern the pattern of classPath (a ant-style string)
@return all URLS
552398
public static Set<URL> getResources(final String locationPattern) {

        final Set<URL> result = new HashSet<URL>();

        final String scanRootPath = getRootPath(locationPattern);
        final String subPattern = locationPattern.substring(scanRootPath.length());
        final Set<URL> rootDirResources = getResourcesFromRoot(scanRootPath);

        for (final URL rootDirResource : rootDirResources) {
            LOGGER.log(Level.INFO, "RootDirResource [protocol={0}, path={1}]",
                    new Object[]{rootDirResource.getProtocol(), rootDirResource.getPath()});

            if (isJarURL(rootDirResource)) {
                result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern));
            } else if (rootDirResource.getProtocol().startsWith(URL_PROTOCOL_VFS)) {
                result.addAll(VfsResourceMatchingDelegate.findMatchingResources(rootDirResource, subPattern));
            } else {
                result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
            }
        }

        return result;
    }
947872
private static String findPattern(Method method, Set<Annotation> methodAnnotations) {
        String pattern = findFirst(method, Path.class).map(Path::value)
                                                      .orElse(null);
        for (Annotation a : methodAnnotations) {
            final String p = (String) invokeValueMethod(a);
            if (DefaultValues.isUnspecified(p)) {
                continue;
            }
            checkArgument(pattern == null,
                          "Only one path can be specified. (" + pattern + ", " + p + ')');
            pattern = p;
        }
        if (pattern == null || pattern.isEmpty()) {
            throw new IllegalArgumentException(
                    "A path pattern should be specified by @Path or HTTP method annotations.");
        }
        return pattern;
    }
444107
public static List<JCAnnotation> findAnnotations(JavacNode fieldNode, Pattern namePattern) {
		ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>();
		for (JavacNode child : fieldNode.down()) {
			if (child.getKind() == Kind.ANNOTATION) {
				JCAnnotation annotation = (JCAnnotation) child.get();
				String name = annotation.annotationType.toString();
				int idx = name.lastIndexOf(".");
				String suspect = idx == -1 ? name : name.substring(idx + 1);
				if (namePattern.matcher(suspect).matches()) {
					result.append(annotation);
				}
			}
		}	
		return result.toList();
	}
92387
public static List<File> listFileWithAntPath(final File rootDir, final String antPathPattern) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir)
				.filter(new AntPathFilter(FilePathUtil.concat(rootDir.getAbsolutePath(), antPathPattern))).toList();
	}
607968
public static List<String> getLocalPaths( String localRepoPath, List<String> notations ) throws NaetherException {
        DefaultServiceLocator locator = new DefaultServiceLocator();
        SimpleLocalRepositoryManagerFactory factory = new SimpleLocalRepositoryManagerFactory();
        factory.initService( locator );

        LocalRepository localRepo = new LocalRepository(localRepoPath);
        LocalRepositoryManager manager = null;
        try {
            manager = factory.newInstance( localRepo );
        } catch (NoLocalRepositoryManagerException e) {
            throw new NaetherException( "Failed to initial local repository manage", e  );
        }

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

        for ( String notation : notations ) {
            Dependency dependency = new Dependency(new DefaultArtifact(notation), "compile");
            File path = new File( localRepo.getBasedir(), manager.getPathForLocalArtifact( dependency.getArtifact() ) );
            localPaths.add( path.toString() );
        }

        return localPaths;
    }
223252
public ResourceHandle findUpwards(String basePath, Pattern namePattern, String childType) {
        ResourceHandle current = this;
        while (current != null && current.isValid()) {
            ResourceHandle base = ResourceHandle.use(current.getChild(basePath));
            if (base.isValid()) {
                for (ResourceHandle child : base.getChildrenByType(childType)) {
                    if (namePattern.matcher(child.getName()).matches()) {
                        return child;
                    }
                }
            }
            current = current.getParent();
        }
        return null;
    }
834150
public static URL[] findClassPaths()
   {
      List<URL> list = new ArrayList<URL>();
      String classpath = System.getProperty("java.class.path");
      StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);

      while (tokenizer.hasMoreTokens())
      {
         String path = tokenizer.nextToken();
         File fp = new File(path);
         if (!fp.exists()) {
        	 throw new RuntimeException("File in java.class.path does not exist: " + fp);
         }
         try
         {
            list.add(fp.toURL());
         }
         catch (MalformedURLException e)
         {
            throw new RuntimeException(e);
         }
      }
      return list.toArray(new URL[list.size()]);
   }
727520
public CellFormatter getFormatter(final String formatPattern) {
        
        final String key = (formatPattern == null ? "" : formatPattern);
        return patternFormatterMap.get(key);
    }
647625
@Override
    public URL getResource(final String path) {
        final ResourceList resourceList = scanResult.getResourcesWithPath(path);
        if (resourceList == null || resourceList.isEmpty()) {
            return super.getResource(path);
        } else {
            return resourceList.get(0).getURL();
        }
    }
806014
@Override
    public List getPatternList() {
        ExtensionFactory delegate = this.delegate;
        if (delegate != null)
            return delegate.getPatternList();
        return Collections.emptyList();
    }
114291
private List<URL> getResources() throws IOException {
        final ClassLoader cl = getClassLoader();

        // ConcurrentHashMap doesn't support null keys, so substitute a pseudo
        // key
        final Object key = cl == null ? NULL_CLASS_LOADER : cl;

        // computeIfAbsent requires unchecked exceptions for the creation
        // process, so we
        // cannot easily use it directly, instead using get and putIfAbsent
        List<URL> newValue = cachedResourceList.get(key);
        if (newValue != null) {
            return newValue;
        }

        if (cl != null) {
            newValue = Collections
                    .unmodifiableList(Collections.list(cl.getResources(JARCACHE_JSON)));
        } else {
            newValue = Collections.unmodifiableList(
                    Collections.list(ClassLoader.getSystemResources(JARCACHE_JSON)));
        }

        final List<URL> oldValue = cachedResourceList.putIfAbsent(key, newValue);
        // We are not synchronising access to the ConcurrentMap, so if there
        // were
        // multiple classpath scans, we always choose the first one
        return oldValue != null ? oldValue : newValue;
    }
143421
public static URL[] getClassPathJars(final Bundle bundle) {
		final List<URL> urls = new ArrayList<>();
		final String bundleClasspath = (String) bundle.getHeaders().get(
				"Bundle-ClassPath");
		if (bundleClasspath != null) {
			String[] segments = bundleClasspath.split(",");
			for (String segment : segments) {
				final URL url = bundle.getEntry(segment);
				if (url != null) {
					if (url.toExternalForm().endsWith("jar")) {
						LOG.debug("Using url: " + url);
						try {
							URL jarUrl = new URL("jar:" + url.toExternalForm()
									+ "!/");
							urls.add(jarUrl);
						} catch (MalformedURLException ignore) {
							LOG.debug(ignore.getMessage());
						}
					}
				}
			}
		}
		LOG.debug("Bundle-ClassPath URLs: " + urls);
		// adds the depending bundles to the "classloader" space
		urls.addAll(getLocationsOfBundlesInClassSpace(bundle));

		return urls.toArray(new URL[urls.size()]);
	}
606899
public static RequestPatternBuilder like(RequestPattern requestPattern) {
        RequestPatternBuilder builder = new RequestPatternBuilder();
        builder.url = requestPattern.getUrlMatcher();
        builder.method = requestPattern.getMethod();
        if (requestPattern.getHeaders() != null) {
            builder.headers = requestPattern.getHeaders();
        }
        if (requestPattern.getQueryParameters() != null) {
            builder.queryParams = requestPattern.getQueryParameters();
        }
        if (requestPattern.getCookies() != null) {
            builder.cookies = requestPattern.getCookies();
        }
        if (requestPattern.getBodyPatterns() != null) {
            builder.bodyPatterns = requestPattern.getBodyPatterns();
        }
        if (requestPattern.hasInlineCustomMatcher()) {
            builder.customMatcher = requestPattern.getMatcher();
        }
        if (requestPattern.getMultipartPatterns() != null) {
            builder.multiparts = requestPattern.getMultipartPatterns();
        }
        builder.basicCredentials = requestPattern.getBasicAuthCredentials();
        builder.customMatcherDefinition = requestPattern.getCustomMatcher();
        return builder;
    }
148286
private static Collection<? extends URL> doFindPathMatchingJarResources(final URL rootDirResource, final String subPattern) {

        final Set<URL> result = new LinkedHashSet<URL>();

        JarFile jarFile = null;
        String jarFileUrl;
        String rootEntryPath = null;
        URLConnection con;
        boolean newJarFile = false;

        try {
            con = rootDirResource.openConnection();

            if (con instanceof JarURLConnection) {
                final JarURLConnection jarCon = (JarURLConnection) con;

                jarCon.setUseCaches(false);
                jarFile = jarCon.getJarFile();
                jarFileUrl = jarCon.getJarFileURL().toExternalForm();
                final JarEntry jarEntry = jarCon.getJarEntry();

                rootEntryPath = jarEntry != null ? jarEntry.getName() : "";
            } else {
                // No JarURLConnection -> need to resort to URL file parsing.
                // We'll assume URLs of the format "jar:path!/entry", with the
                // protocol
                // being arbitrary as long as following the entry format.
                // We'll also handle paths with and without leading "file:"
                // prefix.
                final String urlFile = rootDirResource.getFile();
                final int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR);

                if (separatorIndex != -1) {
                    jarFileUrl = urlFile.substring(0, separatorIndex);
                    rootEntryPath = urlFile.substring(separatorIndex + JAR_URL_SEPARATOR.length());
                    jarFile = getJarFile(jarFileUrl);
                } else {
                    jarFile = new JarFile(urlFile);
                    jarFileUrl = urlFile;
                    rootEntryPath = "";
                }
                newJarFile = true;

            }

        } catch (final IOException e) {
            LOGGER.log(Level.ERROR, "reslove jar File error", e);
            return result;
        }
        try {
            if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) {
                // Root entry path must end with slash to allow for proper
                // matching.
                // The Sun JRE does not return a slash here, but BEA JRockit
                // does.
                rootEntryPath = rootEntryPath + "/";
            }
            for (final Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) {
                final JarEntry entry = (JarEntry) entries.nextElement();
                final String entryPath = entry.getName();

                String relativePath = null;

                if (entryPath.startsWith(rootEntryPath)) {
                    relativePath = entryPath.substring(rootEntryPath.length());

                    if (AntPathMatcher.match(subPattern, relativePath)) {
                        if (relativePath.startsWith("/")) {
                            relativePath = relativePath.substring(1);
                        }
                        result.add(new URL(rootDirResource, relativePath));
                    }
                }
            }
            return result;
        } catch (final IOException e) {
            LOGGER.log(Level.ERROR, "parse the JarFile error", e);
        } finally {
            // Close jar file, but only if freshly obtained -
            // not from JarURLConnection, which might cache the file reference.
            if (newJarFile) {
                try {
                    jarFile.close();
                } catch (final IOException e) {
                    LOGGER.log(Level.WARN, " occur error when closing jarFile", e);
                }
            }
        }
        return result;
    }
93688
protected Set<String> queryQueueNames (String location, String brokerName, String queueNamePattern) throws Exception {
        Set<String> result = new TreeSet<>();

        if ( location.equals("*") ) {
            // TBD222: stop using address (aka location) as the registry key
            for ( String oneLocation : this.brokerRegistry.keys() ) {
                result.addAll(this.queryQueueNames(oneLocation, brokerName, queueNamePattern)); // RECURSION
            }
        } else {
            if ( brokerName.equals("*") ) {
                String[] brokerNames = this.queryBrokerNames(location);

                for ( String oneBrokerName : brokerNames ) {
                    result.addAll(this.queryQueueNames(location, oneBrokerName, queueNamePattern)); // RECURSION
                }
            } else {
                String[] names = this.jmxActiveMQUtil.queryQueueNames(location, brokerName, queueNamePattern);
                result.addAll(Arrays.asList(names));
            }
        }

        return  result;
    }
779684
public ListenableFuture<List<String>> listHosts(final String namePattern) {
    return listHosts(ImmutableMultimap.of("namePattern", namePattern));
  }
200946
public List<URL> getURLs() {
        final List<URL> resourceURLs = new ArrayList<>(this.size());
        for (final Resource resource : this) {
            resourceURLs.add(resource.getURL());
        }
        return resourceURLs;
    }