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

The following examples show how to use org.springframework.util.StringUtils#stripFilenameExtension() . These examples are extracted from open source projects. 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
/**
 * 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 2
/**
 * 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
/**
 * 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
/**
 * 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 5
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 6
public CsvRepository(
    File file,
    EntityTypeFactory entityTypeFactory,
    AttributeFactory attrMetaFactory,
    @Nullable @CheckForNull List<CellProcessor> cellProcessors) {
  this(
      file,
      entityTypeFactory,
      attrMetaFactory,
      StringUtils.stripFilenameExtension(file.getName()),
      cellProcessors);
}
 
Example 7
/**
 * 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 8
/**
 * 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
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 10
@Override
@Nullable
public String suggestedClassName() {
	String filename = getResource().getFilename();
	return (filename != null ? StringUtils.stripFilenameExtension(filename) : null);
}
 
Example 11
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 12
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 13
@Override
@Nullable
public String suggestedClassName() {
	String filename = getResource().getFilename();
	return (filename != null ? StringUtils.stripFilenameExtension(filename) : null);
}
 
Example 14
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 15
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 16
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + '-' + version + '.' + extension);
}
 
Example 17
@Override
public String suggestedClassName() {
	return StringUtils.stripFilenameExtension(getResource().getFilename());
}
 
Example 18
@Override
public String suggestedClassName() {
	return StringUtils.stripFilenameExtension(getResource().getFilename());
}
 
Example 19
@Override
public String addVersion(String requestPath, String version) {
	String baseFilename = StringUtils.stripFilenameExtension(requestPath);
	String extension = StringUtils.getFilenameExtension(requestPath);
	return (baseFilename + "-" + version + "." + extension);
}
 
Example 20
private static String getRepositoryName(String fileName) {
  return StringUtils.stripFilenameExtension(StringUtils.getFilename(fileName));
}