Java Code Examples for org.codehaus.plexus.util.StringUtils#strip()

The following examples show how to use org.codehaus.plexus.util.StringUtils#strip() . 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: AbstractGitFlowMojo.java    From gitflow-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Executes git for-each-ref with <code>refname:short</code> format.
 * 
 * @param refs
 *            Refs to search.
 * @param branchName
 *            Branch name to find.
 * @param firstMatch
 *            Return first match.
 * @return Branch names which matches <code>{refs}{branchName}*</code>.
 * @throws MojoFailureException
 * @throws CommandLineException
 */
private String gitFindBranches(final String refs, final String branchName,
        final boolean firstMatch) throws MojoFailureException,
        CommandLineException {
    String wildcard = "*";
    if (branchName.endsWith("/")) {
        wildcard = "**";
    }

    String branches;
    if (firstMatch) {
        branches = executeGitCommandReturn("for-each-ref", "--count=1",
                "--format=\"%(refname:short)\"", refs + branchName + wildcard);
    } else {
        branches = executeGitCommandReturn("for-each-ref",
                "--format=\"%(refname:short)\"", refs + branchName + wildcard);
    }

    // on *nix systems return values from git for-each-ref are wrapped in
    // quotes
    // https://github.com/aleksandr-m/gitflow-maven-plugin/issues/3
    branches = removeQuotes(branches);
    branches = StringUtils.strip(branches);

    return branches;
}
 
Example 2
Source File: ReorderModifiersTest.java    From Refactoring-Bot with MIT License 5 votes vote down vote up
private boolean assertAllModifiersInCorrectOrder(List<Modifier> modifiers) {
	// Following the JLS, this is the expected order:
	ArrayList<String> modifiersInCorrectOrder = new ArrayList<>();
	modifiersInCorrectOrder.add("public");
	modifiersInCorrectOrder.add("protected");
	modifiersInCorrectOrder.add("private");
	modifiersInCorrectOrder.add("abstract");
	modifiersInCorrectOrder.add("static");
	modifiersInCorrectOrder.add("final");
	modifiersInCorrectOrder.add("transient");
	modifiersInCorrectOrder.add("volatile");
	modifiersInCorrectOrder.add("synchronized");
	modifiersInCorrectOrder.add("native");
	modifiersInCorrectOrder.add("strictfp");

	int lastIndex = 0;
	String nameOfLastModifier = "";
	for (Modifier modifier : modifiers) {
		String modifierName = StringUtils.strip(modifier.toString());
		if (!modifiersInCorrectOrder.contains(modifierName)) {
			throw new IllegalArgumentException("Unknown modifier: " + modifierName);
		}
		int listIndexOfModifier = modifiersInCorrectOrder.indexOf(modifierName);
		if (lastIndex > listIndexOfModifier) {
			throw new AssertionError("Modifier '" + modifierName + "' is expected to be declared before modifier '"
					+ nameOfLastModifier + "'");
		}
		lastIndex = listIndexOfModifier;
		nameOfLastModifier = modifierName;
	}
	return true;
}
 
Example 3
Source File: AbstractGitFlowMojo.java    From gitflow-maven-plugin with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the current branch name.
 * 
 * @return Current branch name.
 * @throws MojoFailureException
 * @throws CommandLineException
 */
protected String gitCurrentBranch() throws MojoFailureException, CommandLineException {
    String name = executeGitCommandReturn("symbolic-ref", "-q", "--short", "HEAD");
    name = StringUtils.strip(name);
    return name;
}