Example usage for org.apache.commons.lang StringUtils removeStart

List of usage examples for org.apache.commons.lang StringUtils removeStart

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils removeStart.

Prototype

public static String removeStart(String str, String remove) 

Source Link

Document

Removes a substring only if it is at the begining of a source string, otherwise returns the source string.

Usage

From source file:org.jboss.loom.utils.as7.AS7ModuleUtils.java

/**
 *  Returns the name of the module which uses given .jar.
 *  For example, file at modules/system/layers/base/com/h2database/h2/main/h2-1.3.168.jar
 *  should return "com.h2database.h2".//from   www  .  j a  va2 s. c o  m
 * 
 *  The current implementation is naive, assuming that the .jar file is in the module's root dir, where module.xml is.
 * 
 *  This method behavior is likely to change with various versions of EAP.
 */
public static String identifyModuleContainingJar(AS7Config as7Config, File jar) {

    String modAbsPath = as7Config.getModulesDir().getPath();
    String jarAbsPath = jar.getParentFile().getParentFile().getPath();

    String commonPrefix = StringUtils.getCommonPrefix(new String[] { modAbsPath, jarAbsPath });
    String diff = jarAbsPath.substring(commonPrefix.length());

    String modName = StringUtils.removeStart(diff, "/");
    return modName.replace('/', '.');
}

From source file:org.jboss.richfaces.integrationTest.push.PushTestCase.java

private void checkPushingProgress() {
    Wait.failWith("Pushing was inactive but should be active").interval(200).timeout(10000)
            .until(new Condition() {
                public boolean isTrue() {
                    return isPushingActive();
                }/*www  . j a  v a  2s .co  m*/
            });

    final String oldOutput = selenium.getText(LOC_OUTPUT_TEXT);

    Wait.failWith("When waiting for text change, it never happen").interval(1000).timeout(20000)
            .until(new Condition() {
                public boolean isTrue() {
                    String actualOutput = selenium.getText(LOC_OUTPUT_TEXT);

                    return !oldOutput.equals(actualOutput);
                }
            });

    String uuid = selenium.getText(LOC_OUTPUT_TEXT);

    assertTrue(uuid.startsWith(MSG_OUTPUT_PUSH_ACTIVE));

    uuid = StringUtils.removeStart(uuid, MSG_OUTPUT_PUSH_ACTIVE);

    assertTrue(StringUtils.isNotBlank(uuid), "Generated UUID should not be blank");
}

From source file:org.jboss.windup.decorator.archive.ClassesProvidedDecorator.java

protected String extractClassName(String entryName) {
    String className = StringUtils.replace(entryName, "\\", "/");
    className = StringUtils.removeStart(className, "/");
    className = StringUtils.replace(className, "/", ".");
    className = StringUtils.removeEnd(className, ".class");
    className = StringUtils.removeEnd(className, ".java");

    // account for WAR classes.
    if (StringUtils.contains(className, "WEB-INF.classes.")) {
        className = StringUtils.substringAfter(className, "WEB-INF.classes.");
    }// w w  w  . j  av a2 s.  c  om
    return className;
}

From source file:org.jboss.windup.decorator.archive.ManifestDecorator.java

protected String cleanseValue(String value) {
    value = StringUtils.trim(value);/*from  w ww .jav  a  2s . c  o m*/
    value = StringUtils.removeStart(value, "'");
    value = StringUtils.removeStart(value, "\"");
    value = StringUtils.removeEnd(value, "\"");
    value = StringUtils.removeEnd(value, "'");
    value = StringUtils.trim(value);

    return value;
}

From source file:org.jboss.windup.decorator.java.JavaASTAnnotationVisitor.java

protected String extract(StringLiteral value) {
    String val = value.toString();
    val = StringUtils.removeStart(val, "\"");
    val = StringUtils.removeEnd(val, "\"");

    return val;
}

From source file:org.jboss.windup.decorator.java.JavaASTVariableResolvingVisitor.java

public boolean visit(MethodInvocation node) {
    if (!StringUtils.contains(node.toString(), ".")) {
        // it must be a local method. ignore.
        return true;
    }//from   w  w w .jav a2  s.com

    String nodeName = StringUtils.removeStart(node.toString(), "this.");

    List arguements = node.arguments();
    List<String> resolvedParams = methodParameterGuesser(arguements);

    String objRef = StringUtils.substringBefore(nodeName, "." + node.getName().toString());

    if (nameInstance.containsKey(objRef)) {
        objRef = nameInstance.get(objRef);
    }

    if (classNameToFullyQualified.containsKey(objRef)) {
        objRef = classNameToFullyQualified.get(objRef);
    }
    String resolvedMethodCall = objRef + "." + node.getName().toString() + "(";

    for (int i = 0, j = resolvedParams.size(); i < j; i++) {
        resolvedMethodCall += resolvedParams.get(i);

        if (i < j - 1) {
            resolvedMethodCall += ", ";
        }
    }
    resolvedMethodCall = resolvedMethodCall + ")";
    LOG.trace("Resolved Method call: " + resolvedMethodCall);
    // Here is the call to blacklist
    processInterest(resolvedMethodCall, cu.getLineNumber(node.getStartPosition()), "Usage of",
            SourceType.METHOD);

    return true;
}

From source file:org.jboss.windup.interrogator.impl.ClassInterrogator.java

protected String extractClassName(String entryName) {
    String className = StringUtils.replace(entryName, "\\", "/");
    className = StringUtils.removeStart(className, "/");
    className = StringUtils.replace(className, "/", ".");
    className = StringUtils.removeEnd(className, ".class");
    className = StringUtils.removeEnd(className, ".java");
    className = StringUtils.substringBefore(className, "$");

    // account for WAR classes.
    if (StringUtils.contains(className, "WEB-INF.classes.")) {
        className = StringUtils.substringAfter(className, "WEB-INF.classes.");
    }/*w  w  w .  j  av a 2  s. c o m*/
    return className;
}

From source file:org.jboss.windup.interrogator.util.KnownArchiveProfiler.java

protected String getClassNameFromFile(String entryName) {
    String className = StringUtils.replace(entryName, "\\", "/");
    className = StringUtils.removeStart(className, "/");
    className = StringUtils.replace(className, "/", ".");
    className = StringUtils.substringBefore(className, "$");

    // account for WAR classes.
    if (StringUtils.contains(className, "WEB-INF.classes.")) {
        className = StringUtils.substringAfter(className, "WEB-INF.classes.");
    }/* w  ww  .  ja v a 2 s. com*/
    if (StringUtils.contains(className, "META-INF.classes.")) {
        className = StringUtils.substringAfter(className, "META-INF.classes.");
    }
    return className;
}

From source file:org.jboss.windup.metadata.decoration.Interrogation.java

protected String getArchiveRelativePath() {
    String basePath = this.archiveDirectory.getAbsolutePath();
    String finalRelative = StringUtils.removeStart(this.result.getAbsolutePath(), basePath);

    finalRelative = StringUtils.replace(finalRelative, "\\", "/");
    finalRelative = StringUtils.replace(finalRelative, "//", "/");
    finalRelative = StringUtils.removeStart(finalRelative, "/");

    return finalRelative;
}

From source file:org.jboss.windup.metadata.decoration.Interrogation.java

protected String getReportRelativePath() {
    String basePath = this.reportDirectory.getAbsolutePath();
    String finalRelative = StringUtils.removeStart(this.result.getAbsolutePath(), basePath);

    finalRelative = StringUtils.replace(finalRelative, "\\", "/");
    finalRelative = StringUtils.replace(finalRelative, "//", "/");
    finalRelative = StringUtils.removeStart(finalRelative, "/");

    return finalRelative;
}