List of usage examples for org.springframework.util StringUtils delete
public static String delete(String inString, String pattern)
From source file:com.reactive.hzdfs.dll.JarClassLoader.java
private static TreeSet<String> scanForPackages(String path) throws IOException { try (JarFile file = new JarFile(path)) { TreeSet<String> packages = new TreeSet<>(new Comparator<String>() { @Override/*from www . java2s . c o m*/ public int compare(String o1, String o2) { if (o2.length() > o1.length() && o2.contains(o1)) return -1; else if (o2.length() < o1.length() && o1.contains(o2)) return 1; else return o1.compareTo(o2); } }); for (Enumeration<JarEntry> entries = file.entries(); entries.hasMoreElements();) { JarEntry entry = entries.nextElement(); String name = entry.getName(); if (name.endsWith(".class")) { String fqcn = ClassUtils.convertResourcePathToClassName(name); fqcn = StringUtils.delete(fqcn, ".class"); packages.add(ClassUtils.getPackageName(fqcn)); } } return packages; } }
From source file:org.springframework.web.reactive.resource.AbstractFileNameVersionStrategy.java
@Override public String removeVersion(String requestPath, String version) { return StringUtils.delete(requestPath, "-" + version); }
From source file:org.springframework.web.servlet.resource.FingerprintResourceResolver.java
@Override public Resource resolveResource(HttpServletRequest request, String requestPath, List<Resource> locations, ResourceResolverChain chain) {//from w w w . ja v a 2s . c o m Resource resolved = chain.resolveResource(request, requestPath, locations); if (resolved != null) { return resolved; } String hash = extractHash(requestPath); if (StringUtils.isEmpty(hash)) { return null; } String simplePath = StringUtils.delete(requestPath, "-" + hash); Resource baseResource = chain.resolveResource(request, simplePath, locations); if (baseResource == null) { return null; } String candidateHash = calculateHash(baseResource); if (candidateHash.equals(hash)) { return baseResource; } else { logger.debug("Potential resource found for [" + requestPath + "], but fingerprint doesn't match."); return null; } }
From source file:org.springframework.web.servlet.resource.PathExtensionResourceResolver.java
@Override public Resource resolveResource(HttpServletRequest request, String requestPath, List<Resource> locations, ResourceResolverChain chain) {//from ww w. ja va2 s.c o m Resource resource = chain.resolveResource(request, requestPath, locations); if ((resource != null) && !this.compareTimeStamp) { return resource; } for (Resource location : locations) { String baseFilename = StringUtils.getFilename(requestPath); try { Resource basePath = location.createRelative(StringUtils.delete(requestPath, baseFilename)); if (basePath.getFile().isDirectory()) { for (String fileName : basePath.getFile().list(new ExtensionFilenameFilter(baseFilename))) { //Always use the first match Resource matched = basePath.createRelative(fileName); if ((resource == null) || (matched.lastModified() > resource.lastModified())) { return matched; } else { return resource; } } } } catch (IOException e) { logger.trace("Error occurred locating resource based on file extension mapping", e); } } return resource; }