/** * Creates a new location. * * @param descriptor The location descriptor. */ public Location(String descriptor) { String normalizedDescriptor = descriptor.trim().replace("\\", "/"); if (normalizedDescriptor.contains(":")) { prefix = normalizedDescriptor.substring(0, normalizedDescriptor.indexOf(":") + 1); path = normalizedDescriptor.substring(normalizedDescriptor.indexOf(":") + 1); } else { prefix = CLASSPATH_PREFIX; path = normalizedDescriptor; } if (isClassPath()) { path = path.replace(".", "/"); if (path.startsWith("/")) { path = path.substring(1); } } else { if (!isFileSystem()) { throw new ClassPathScanException("Unknown prefix, should be either filesystem: or classpath: " + normalizedDescriptor); } } if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } }
/** * Scans this location for resources matching the given predicate. * <p> * The location can have a prefix of <code>filesystem:</code> or <code>classpath:</code> to determine * how to scan. If no prefix is used then classpath scan is the default. * </p> * * @param location The location to start searching. Subdirectories are also searched. * @param predicate The predicate used to match resource names. * @return The resources that were found. */ public List<Resource> scanForResources(Location location, ResourceFilter predicate) { if (location.isFileSystem()) { return fileSystemScanner.scanForResources(location, predicate); } return resourceAndClassScanner.scanForResources(location, predicate); }