Java Code Examples for org.springframework.util.StringUtils#stripFilenameExtension()

The following examples show how to use org.springframework.util.StringUtils#stripFilenameExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericResourceRepository.java    From spring-cloud-config with Apache License 2.0 6 votes vote down vote up
private Collection<String> getProfilePaths(String profiles, String path) {
	Set<String> paths = new LinkedHashSet<>();
	for (String profile : StringUtils.commaDelimitedListToSet(profiles)) {
		if (!StringUtils.hasText(profile) || "default".equals(profile)) {
			paths.add(path);
		}
		else {
			String ext = StringUtils.getFilenameExtension(path);
			String file = path;
			if (ext != null) {
				ext = "." + ext;
				file = StringUtils.stripFilenameExtension(path);
			}
			else {
				ext = "";
			}
			paths.add(file + "-" + profile + ext);
		}
	}
	paths.add(path);
	return paths;
}
 
Example 2
Source File: DefaultRequestToViewNameTranslator.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Transform the request URI (in the context of the webapp) stripping
 * slashes and extensions, and replacing the separator as required.
 * @param lookupPath the lookup path for the current request,
 * as determined by the UrlPathHelper
 * @return the transformed path, with slashes and extensions stripped
 * if desired
 */
@Nullable
protected String transformPath(String lookupPath) {
	String path = lookupPath;
	if (this.stripLeadingSlash && path.startsWith(SLASH)) {
		path = path.substring(1);
	}
	if (this.stripTrailingSlash && path.endsWith(SLASH)) {
		path = path.substring(0, path.length() - 1);
	}
	if (this.stripExtension) {
		path = StringUtils.stripFilenameExtension(path);
	}
	if (!SLASH.equals(this.separator)) {
		path = StringUtils.replace(path, SLASH, this.separator);
	}
	return path;
}
 
Example 3
Source File: DefaultRequestToViewNameTranslator.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Transform the request URI (in the context of the webapp) stripping
 * slashes and extensions, and replacing the separator as required.
 * @param lookupPath the lookup path for the current request,
 * as determined by the UrlPathHelper
 * @return the transformed path, with slashes and extensions stripped
 * if desired
 */
protected String transformPath(String lookupPath) {
	String path = lookupPath;
	if (this.stripLeadingSlash && path.startsWith(SLASH)) {
		path = path.substring(1);
	}
	if (this.stripTrailingSlash && path.endsWith(SLASH)) {
		path = path.substring(0, path.length() - 1);
	}
	if (this.stripExtension) {
		path = StringUtils.stripFilenameExtension(path);
	}
	if (!SLASH.equals(this.separator)) {
		path = StringUtils.replace(path, SLASH, this.separator);
	}
	return path;
}
 
Example 4
Source File: DefaultRequestToViewNameTranslator.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Transform the request URI (in the context of the webapp) stripping
 * slashes and extensions, and replacing the separator as required.
 * @param lookupPath the lookup path for the current request,
 * as determined by the UrlPathHelper
 * @return the transformed path, with slashes and extensions stripped
 * if desired
 */
@Nullable
protected String transformPath(String lookupPath) {
	String path = lookupPath;
	if (this.stripLeadingSlash && path.startsWith(SLASH)) {
		path = path.substring(1);
	}
	if (this.stripTrailingSlash && path.endsWith(SLASH)) {
		path = path.substring(0, path.length() - 1);
	}
	if (this.stripExtension) {
		path = StringUtils.stripFilenameExtension(path);
	}
	if (!SLASH.equals(this.separator)) {
		path = StringUtils.replace(path, SLASH, this.separator);
	}
	return path;
}
 
Example 5
Source File: DefaultRequestToViewNameTranslator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Transform the request URI (in the context of the webapp) stripping
 * slashes and extensions, and replacing the separator as required.
 * @param lookupPath the lookup path for the current request,
 * as determined by the UrlPathHelper
 * @return the transformed path, with slashes and extensions stripped
 * if desired
 */
protected String transformPath(String lookupPath) {
	String path = lookupPath;
	if (this.stripLeadingSlash && path.startsWith(SLASH)) {
		path = path.substring(1);
	}
	if (this.stripTrailingSlash && path.endsWith(SLASH)) {
		path = path.substring(0, path.length() - 1);
	}
	if (this.stripExtension) {
		path = StringUtils.stripFilenameExtension(path);
	}
	if (!SLASH.equals(this.separator)) {
		path = StringUtils.replace(path, SLASH, this.separator);
	}
	return path;
}
 
Example 6
Source File: ViewResolutionResultHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Select a default view name when a controller did not specify it.
 * Use the request path the leading and trailing slash stripped.
 */
private String getDefaultViewName(ServerWebExchange exchange) {
	String path = exchange.getRequest().getPath().pathWithinApplication().value();
	if (path.startsWith("/")) {
		path = path.substring(1);
	}
	if (path.endsWith("/")) {
		path = path.substring(0, path.length() - 1);
	}
	return StringUtils.stripFilenameExtension(path);
}
 
Example 7
Source File: CsvRepository.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CsvRepository(
    File file,
    EntityTypeFactory entityTypeFactory,
    AttributeFactory attrMetaFactory,
    @Nullable @CheckForNull List<CellProcessor> cellProcessors,
    Character separator) {
  this(
      file,
      entityTypeFactory,
      attrMetaFactory,
      StringUtils.stripFilenameExtension(file.getName()),
      cellProcessors);
  this.separator = separator;
}
 
Example 8
Source File: ViewResolutionResultHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Select a default view name when a controller did not specify it.
 * Use the request path the leading and trailing slash stripped.
 */
private String getDefaultViewName(ServerWebExchange exchange) {
	String path = exchange.getRequest().getPath().pathWithinApplication().value();
	if (path.startsWith("/")) {
		path = path.substring(1);
	}
	if (path.endsWith("/")) {
		path = path.substring(0, path.length() - 1);
	}
	return StringUtils.stripFilenameExtension(path);
}
 
Example 9
Source File: CsvRepository.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CsvRepository(
    File file,
    EntityTypeFactory entityTypeFactory,
    AttributeFactory attrMetaFactory,
    @Nullable @CheckForNull List<CellProcessor> cellProcessors) {
  this(
      file,
      entityTypeFactory,
      attrMetaFactory,
      StringUtils.stripFilenameExtension(file.getName()),
      cellProcessors);
}
 
Example 10
Source File: AbstractVersionStrategy.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 11
Source File: CsvRepositoryCollection.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static String getRepositoryName(String fileName) {
  return StringUtils.stripFilenameExtension(StringUtils.getFilename(fileName));
}
 
Example 12
Source File: AbstractVersionStrategy.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + "-" + version + "." + extension);
}
 
Example 13
Source File: ResourceScriptSource.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public String suggestedClassName() {
	return StringUtils.stripFilenameExtension(getResource().getFilename());
}
 
Example 14
Source File: ResourceScriptSource.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String suggestedClassName() {
	return StringUtils.stripFilenameExtension(getResource().getFilename());
}
 
Example 15
Source File: AbstractVersionStrategy.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 16
Source File: AbstractFileNameVersionStrategy.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 17
Source File: ResourceScriptSource.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@Nullable
public String suggestedClassName() {
	String filename = getResource().getFilename();
	return (filename != null ? StringUtils.stripFilenameExtension(filename) : null);
}
 
Example 18
Source File: AbstractVersionStrategy.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 19
Source File: AbstractFileNameVersionStrategy.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 20
Source File: ResourceScriptSource.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@Nullable
public String suggestedClassName() {
	String filename = getResource().getFilename();
	return (filename != null ? StringUtils.stripFilenameExtension(filename) : null);
}