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

The following examples show how to use org.springframework.util.StringUtils#trimLeadingCharacter() . 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
private String constructValidUrl(String scheme, String hostname, int port,
		String contextPath, String statusPath) {
	try {
		if (!contextPath.endsWith("/")) {
			contextPath = contextPath + "/";
		}
		String refinedContextPath = '/'
				+ StringUtils.trimLeadingCharacter(contextPath, '/');
		URL base = new URL(scheme, hostname, port, refinedContextPath);
		String refinedStatusPath = refinedStatusPath(statusPath, contextPath);
		return new URL(base, refinedStatusPath).toString();
	}
	catch (MalformedURLException e) {
		String message = getErrorMessage(scheme, hostname, port, contextPath,
				statusPath);
		throw new IllegalStateException(message, e);
	}
}
 
Example 2
Source Project: mojito   File: CSVFilter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Overriding to trim comment/note
 *
 * Trimming is needed because the comment in the CSV is often escaped with quotes, but the okapi filter
 * does not trim quotes from comment automatically.
 *
 * @param textUnit
 * @return
 */
@Override
protected boolean processTU(ITextUnit textUnit) {

    Property note = textUnit.getProperty(Property.NOTE);
    if (note != null) {
        String comments = note.toString();
        char quote = "\"".charAt(0);
        comments = StringUtils.trimLeadingCharacter(comments, quote);
        comments = StringUtils.trimTrailingCharacter(comments, quote);
        note.setValue(comments);
    }

    return super.processTU(textUnit);
}
 
Example 3
Source Project: booties   File: StringToLinkRelation.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public LinkRelation apply(String input) {
	Iterable<String> splittResult = splitter.split(input);
	String link = Iterables.get(splittResult, 0);
	link = StringUtils.trimAllWhitespace(link);
	link = StringUtils.trimLeadingCharacter(link, '<');
	link = StringUtils.trimTrailingCharacter(link, '>');
	String relation = Iterables.get(splittResult, 1);
	relation = StringUtils.trimAllWhitespace(relation);
	return new LinkRelation(link, relation);
}
 
Example 4
private String refinedStatusPath(String statusPath, String contextPath) {
	if (statusPath.startsWith(contextPath) && !"/".equals(contextPath)) {
		statusPath = StringUtils.replace(statusPath, contextPath, "");
	}
	return StringUtils.trimLeadingCharacter(statusPath, '/');
}
 
Example 5
private String extractFileName(URI root, URI resource) {
	String candidate = resource.toString().substring(root.toString().length());
	return StringUtils.trimLeadingCharacter(candidate, '/');
}
 
Example 6
private static String trim(String s, char charToTrim) {
    
    String result = StringUtils.trimLeadingCharacter(s, charToTrim);
    result = StringUtils.trimTrailingCharacter(result, charToTrim);
    
    return result;
}