Java Code Examples for org.springframework.util.StringUtils.getFilename()

The following are Jave code examples for showing how to use getFilename() of the org.springframework.util.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: artifactory-resource   File: MavenMetadataGenerator.java   View Source Code Vote up 5 votes
private void generate(Directory root, File pomFile) {
	String name = StringUtils.getFilename(pomFile.getName());
	String extension = StringUtils.getFilenameExtension(pomFile.getName());
	String prefix = name.substring(0, name.length() - extension.length() - 1);
	File[] files = pomFile.getParentFile().listFiles((f) -> include(f, prefix));
	MultiValueMap<File, MavenCoordinates> coordinates = new LinkedMultiValueMap<>();
	for (File file : files) {
		String rootPath = StringUtils.cleanPath(root.getFile().getPath());
		String relativePath = StringUtils.cleanPath(file.getPath())
				.substring(rootPath.length() + 1);
		coordinates.add(file.getParentFile(),
				MavenCoordinates.fromPath(relativePath));
	}
	coordinates.forEach(this::writeMetadata);
}
 
Example 2
Project: gemini.blueprint   File: AbstractOnTheFlyBundleCreatorTests.java   View Source Code Vote up 4 votes
private String[] determineImportsFor(Map entries) {
	// get contained packages to do matching on the test hierarchy
	Collection containedPackages = jarCreator.getContainedPackages();
	Set cumulatedPackages = new LinkedHashSet();

	// make sure the collection package is valid
	boolean validPackageCollection = !containedPackages.isEmpty();

	boolean trace = logger.isTraceEnabled();

	for (Iterator iterator = entries.entrySet().iterator(); iterator.hasNext();) {
		Map.Entry entry = (Map.Entry) iterator.next();
		String resourceName = (String) entry.getKey();

		// filter out the test hierarchy
		if (resourceName.endsWith(ClassUtils.CLASS_FILE_SUFFIX)) {
			if (trace) {
				logger.trace("Analyze imports for test bundle resource " + resourceName);
               }
			String classFileName = StringUtils.getFilename(resourceName);
			String className = classFileName.substring(0, classFileName.length() - ClassUtils.CLASS_FILE_SUFFIX.length());
			String classPkg = resourceName.substring(0, resourceName.length() - classFileName.length()).replace('/', '.');

			if (classPkg.startsWith(".")) {
				classPkg = classPkg.substring(1);
               }

			if (classPkg.endsWith(".")) {
				classPkg = classPkg.substring(0, classPkg.length() - 1);
               }

			// if we don't have the package, add it
			if (validPackageCollection && StringUtils.hasText(classPkg) && !containedPackages.contains(classPkg)) {
			    if (trace) {
					logger.trace("Package [" + classPkg + "] is NOT part of the test archive; adding an import for it");
                   }
				cumulatedPackages.add(classPkg);
			}

			// otherwise parse the class byte-code
			else {
				if (trace) {
					logger.trace("Package [" + classPkg + "] is part of the test archive; parsing " + className + " bytecode to determine imports...");
                   }
				cumulatedPackages.addAll(determineImportsForClass(className, (Resource) entry.getValue()));
			}
		}
	}

	return (String[]) cumulatedPackages.toArray(new String[cumulatedPackages.size()]);
}
 
Example 3
Project: gemini.blueprint   File: OsgiBundleResource.java   View Source Code Vote up 2 votes
/**
 * Returns the filename of this resources. This implementation returns the
 * name of the file that this bundle path resource refers to.
 * 
 * @return resource filename
 * @see org.springframework.util.StringUtils#getFilename(String)
 */
public String getFilename() {
	return StringUtils.getFilename(this.path);
}
 
Example 4
Project: lams   File: ServletContextResource.java   View Source Code Vote up 2 votes
/**
 * This implementation returns the name of the file that this ServletContext
 * resource refers to.
 * @see org.springframework.util.StringUtils#getFilename(String)
 */
@Override
public String getFilename() {
	return StringUtils.getFilename(this.path);
}