List of usage examples for org.apache.commons.lang3 StringUtils removeStart
public static String removeStart(final String str, final String remove)
Removes a substring only if it is at the beginning of a source string, otherwise returns the source string.
A null source string will return null .
From source file:cop.raml.processor.Resource.java
public void removePathPrefix(String prefix) { if (StringUtils.isNotBlank(prefix)) { path = StringUtils.removeStart(path, prefix); // for (String key : children.keySet()) { // Resource resource = children.replace(key); // resource.removePathPrefix(prefix); // children.put(resource.path, resource); // } }/*from w w w. ja va 2s . c o m*/ }
From source file:ch.cyberduck.core.onedrive.OneDriveSearchFeature.java
@Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> list = new AttributedList<>(); // The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content. final Iterator<OneDriveItem.Metadata> iterator = session.toFolder(workdir) .search(regex.toPattern().pattern()).iterator(); while (iterator.hasNext()) { final OneDriveItem.Metadata metadata; try {/*from w w w. j a va2 s . c o m*/ metadata = iterator.next(); } catch (OneDriveRuntimeException e) { log.warn(e); continue; } list.add( new Path( String.format("/%s/%s/%s", metadata.getParentReference().getDriveId(), StringUtils.removeStart(metadata.getParentReference().getPath(), "/drive/root:"), metadata.getName()), metadata.isFolder() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attributes.convert(metadata))); } return list; }
From source file:com.xpn.xwiki.internal.filter.XWikiDocumentFilterUtilsTest.java
private void assertXML(Object entity, String resource) throws FilterException, IOException, ComponentLookupException { URL url = getClass().getResource("/filter/xar/" + resource + ".xml"); assertNotNull(url);//from w w w . ja v a 2 s .c o m String expected = IOUtils.toString(url, "UTF-8"); expected = StringUtils.removeStart(expected, "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n\n"); // Import Object importedEntity = this.mocker.getComponentUnderTest().importEntity(entity, new DefaultURLInputSource(url)); // Export String actual = this.mocker.getComponentUnderTest().exportEntity(importedEntity); // Validate assertEquals(expected, actual); }
From source file:ch.cyberduck.core.shared.DefaultHomeFinderService.java
@Override public Path find(final Path root, final String path) { if (path.startsWith(String.valueOf(Path.DELIMITER))) { // Mount absolute path final String normalized = this.normalize(path, true); return new Path(normalized, normalized.equals(String.valueOf(Path.DELIMITER)) ? EnumSet.of(Path.Type.volume, Path.Type.directory) : EnumSet.of(Path.Type.directory)); } else {/*w w w.j av a 2 s. co m*/ if (path.startsWith(Path.HOME)) { // Relative path to the home directory return new Path(root, this.normalize(StringUtils.removeStart(StringUtils.removeStart(path, Path.HOME), String.valueOf(Path.DELIMITER)), false), EnumSet.of(Path.Type.directory)); } else { // Relative path return new Path(root, this.normalize(path, false), EnumSet.of(Path.Type.directory)); } } }
From source file:com.technophobia.substeps.model.PatternMap.java
public List<V> getRelaxedValue(final String sourceKey, final String[] keywordPrecedence) { // TODO - lookup in the relaxed map, based on the keyword precedence String baseLine = null;// w w w. j a v a 2s . com for (final String altKeyword : keywordPrecedence) { baseLine = StringUtils.removeStart(sourceKey, altKeyword); if (!baseLine.equals(sourceKey)) { break; } } List<V> vals = null; for (final String altKeyword : keywordPrecedence) { vals = get(altKeyword + baseLine); if (!vals.isEmpty()) { break; } } return vals; }
From source file:ch.cyberduck.core.b2.B2SingleUploadService.java
@Override protected void post(final Path file, final MessageDigest digest, final BaseB2Response response) throws BackgroundException { this.verify(file, digest, Checksum .parse(StringUtils.removeStart(((B2FileResponse) response).getContentSha1(), "unverified:"))); }
From source file:com.chiorichan.http.Route.java
/** * * @param args//from w ww . j ava2 s . co m * Line input in the format of "pattern '/dir/[cat=]/[id=]', to '/dir/view_item.gsp'" * @throws IOException * Thrown if input string is not valid */ public Route(String args, Site site) throws IOException { if (args == null || args.isEmpty()) throw new IOException("args can't be null or empty"); this.site = site; type = RouteType.FILE; for (String o : args.split(",")) { String key = null; String val = null; o = o.trim(); if (o.contains(":")) { key = o.substring(0, o.indexOf(":")); val = o.substring(o.indexOf(":") + 1); } else if (!o.contains("\"") && !o.contains("'") || o.contains("\"") && o.indexOf(" ") < o.indexOf("\"") || o.contains("'") && o.indexOf(" ") < o.indexOf("'")) { key = o.substring(0, o.indexOf(" ")); val = o.substring(o.indexOf(" ") + 1); } if (key != null && val != null) { key = StringUtils.trimToEmpty(key.toLowerCase()); val = StringUtils.trimToEmpty(val); val = StringUtils.removeStart(val, "\""); val = StringUtils.removeStart(val, "'"); val = StringUtils.removeEnd(val, "\""); val = StringUtils.removeEnd(val, "'"); params.put(key, val); } } // params.put( "domain", site.getDomain() ); }
From source file:ch.cyberduck.core.ftp.FTPStatListService.java
protected List<String> parse(final int response, final String[] reply) { final List<String> result = new ArrayList<String>(reply.length); for (final String line : reply) { // Some servers include the status code for every line. if (line.startsWith(String.valueOf(response))) { try { String stripped = line; stripped = StringUtils.strip( StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response)))); stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response))); result.add(stripped);/* www . ja v a 2 s . c o m*/ } catch (IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.strip(line)); } } return result; }
From source file:jodtemplate.pptx.postprocessor.StylePostprocessor.java
private void processComment(final Comment comment, final Element at, final Slide slide, final Configuration configuration) throws JODTemplateException { String commentText = comment.getText(); if (commentText.startsWith(STYLIZED_KEYWORD)) { commentText = StringUtils.removeStart(commentText, STYLIZED_KEYWORD); final String className = StringUtils.substringBefore(commentText, ":"); commentText = StringUtils.removeStart(commentText, className + ": "); final Stylizer stylizer = configuration.getStylizer(className); if (stylizer == null) { throw new JODTemplateException("Unable to find stylizer"); }// w w w .j a v a2s . c om final String text = StringUtils.removeStart(commentText, " stylized: "); final Element ar = at.getParentElement(); final Element ap = ar.getParentElement(); final int arIndex = ap.indexOf(ar); final Element arPr = getArPrElement(ar); final Element apPr = getApPrElement(ap); final Element sourceApPr = ObjectUtils.clone(apPr); cleanApPrElement(apPr); final List<Element> stylizedElements = stylizer.stylize(text, arPr, apPr, slide); ap.removeContent(ar); final List<Element> remains = getRemainingElements(arIndex, ap); for (Element el : remains) { ap.removeContent(el); } final int currentApIndex = injectElementsInDocument(stylizedElements, ap, apPr, arIndex); injectRemainsInDocument(remains, ap, sourceApPr, currentApIndex); } }
From source file:io.lavagna.web.security.CSFRFilter.java
/** * Return true if the filter must check the request * * @param request/*from w ww . j a v a 2s . c o m*/ * @return */ private boolean mustCheckCSRF(HttpServletRequest request) { // ignore the websocket fallback... if ("POST".equals(request.getMethod()) && WEBSOCKET_FALLBACK .matcher(StringUtils.removeStart(request.getRequestURI(), request.getContextPath())).matches()) { return false; } return !CSRF_METHOD_DONT_CHECK.matcher(request.getMethod()).matches(); }