當前位置: 首頁>>代碼示例>>Java>>正文


Java PathMatcher.matchStart方法代碼示例

本文整理匯總了Java中org.springframework.util.PathMatcher.matchStart方法的典型用法代碼示例。如果您正苦於以下問題:Java PathMatcher.matchStart方法的具體用法?Java PathMatcher.matchStart怎麽用?Java PathMatcher.matchStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.util.PathMatcher的用法示例。


在下文中一共展示了PathMatcher.matchStart方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findImportedBundleMatchingResource

import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
/**
 * Searches for the given pattern inside the imported bundle. This translates to pattern matching on the imported
 * packages.
 * 
 * @param importedBundle imported bundle
 * @param path path used for pattern matching
 * @param foundPaths collection of found results
 */
@SuppressWarnings("unchecked")
private void findImportedBundleMatchingResource(final ImportedBundle importedBundle, String rootPath, String path,
		final Collection<String> foundPaths) throws IOException {

	final boolean trace = logger.isTraceEnabled();

	String[] packages = importedBundle.getImportedPackages();

	if (trace)
		logger.trace("Searching path [" + path + "] on imported pkgs " + ObjectUtils.nullSafeToString(packages)
				+ "...");

	final boolean startsWithSlash = rootPath.startsWith(FOLDER_SEPARATOR);

	for (int i = 0; i < packages.length; i++) {
		// transform the package name into a path
		String pkg = packages[i].replace(DOT, SLASH) + SLASH;

		if (startsWithSlash) {
			pkg = FOLDER_SEPARATOR + pkg;
		}

		final PathMatcher matcher = getPathMatcher();
		// if the imported package matches the path
		if (matcher.matchStart(path, pkg)) {
			Bundle bundle = importedBundle.getBundle();
			// 1. look at the Bundle jar root
			Enumeration<String> entries = bundle.getEntryPaths(pkg);
			while (entries != null && entries.hasMoreElements()) {
				String entry = entries.nextElement();
				if (startsWithSlash)
					entry = FOLDER_SEPARATOR + entry;

				if (matcher.match(path, entry)) {
					if (trace)
						logger.trace("Found entry [" + entry + "]");
					foundPaths.add(entry);
				}
			}
			// 2. Do a Bundle-Classpath lookup (since the jar might use a different classpath)
			Collection<String> cpMatchingPaths = findBundleClassPathMatchingPaths(bundle, path);
			foundPaths.addAll(cpMatchingPaths);
		}
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:54,代碼來源:OsgiBundleResourcePatternResolver.java

示例2: findImportedBundleMatchingResource

import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
/**
 * Searches for the given pattern inside the imported bundle. This
 * translates to pattern matching on the imported packages.
 * 
 * @param importedBundle imported bundle
 * @param path path used for pattern matching
 * @param foundPaths collection of found results
 */
private void findImportedBundleMatchingResource(final ImportedBundle importedBundle, String rootPath, String path,
		final Collection foundPaths) throws IOException {

	final boolean trace = logger.isTraceEnabled();

	String[] packages = importedBundle.getImportedPackages();

	if (trace)
		logger.trace("Searching path [" + path + "] on imported pkgs " + ObjectUtils.nullSafeToString(packages)
				+ "...");

	final boolean startsWithSlash = rootPath.startsWith(FOLDER_SEPARATOR);

	for (int i = 0; i < packages.length; i++) {
		// transform the package name into a path
		String pkg = packages[i].replace(DOT, SLASH) + SLASH;

		if (startsWithSlash) {
			pkg = FOLDER_SEPARATOR + pkg;
		}

		final PathMatcher matcher = getPathMatcher();
		// if the imported package matches the path
		if (matcher.matchStart(path, pkg)) {
			Bundle bundle = importedBundle.getBundle();
			// 1. look at the Bundle jar root
			Enumeration entries = bundle.getEntryPaths(pkg);
			while (entries != null && entries.hasMoreElements()) {
				String entry = (String) entries.nextElement();
				if (startsWithSlash)
					entry = FOLDER_SEPARATOR + entry;

				if (matcher.match(path, entry)) {
					if (trace)
						logger.trace("Found entry [" + entry + "]");
					foundPaths.add(entry);
				}
			}
			// 2. Do a Bundle-Classpath lookup (since the jar might use a different classpath)
			Collection cpMatchingPaths = findBundleClassPathMatchingPaths(bundle, path);
			foundPaths.addAll(cpMatchingPaths);
		}
	}
}
 
開發者ID:BeamFoundry,項目名稱:spring-osgi,代碼行數:53,代碼來源:OsgiBundleResourcePatternResolver.java


注:本文中的org.springframework.util.PathMatcher.matchStart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。