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

The following examples show how to use org.springframework.util.StringUtils#trimLeadingCharacter() . 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: DefaultManagementMetadataProvider.java    From spring-cloud-netflix with Apache License 2.0 6 votes vote down vote up
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 File: CSVFilter.java    From mojito with 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 File: StringToLinkRelation.java    From booties with 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
Source File: DefaultManagementMetadataProvider.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
private String refinedStatusPath(String statusPath, String contextPath) {
	if (statusPath.startsWith(contextPath) && !"/".equals(contextPath)) {
		statusPath = StringUtils.replace(statusPath, contextPath, "");
	}
	return StringUtils.trimLeadingCharacter(statusPath, '/');
}
 
Example 5
Source File: MultipleResourcesProjectContributor.java    From initializr with Apache License 2.0 4 votes vote down vote up
private String extractFileName(URI root, URI resource) {
	String candidate = resource.toString().substring(root.toString().length());
	return StringUtils.trimLeadingCharacter(candidate, '/');
}
 
Example 6
Source File: BlockTestingResourcesFilter.java    From verigreen with Apache License 2.0 3 votes vote down vote up
private static String trim(String s, char charToTrim) {
    
    String result = StringUtils.trimLeadingCharacter(s, charToTrim);
    result = StringUtils.trimTrailingCharacter(result, charToTrim);
    
    return result;
}