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

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

Introduction

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

Prototype

public static String removeEndIgnoreCase(String str, String remove) 

Source Link

Document

Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.

Usage

From source file:org.ednovo.gooru.domain.service.resource.ResourceServiceImpl.java

private String cleanTitle(String title) {
    final List<String> stringsToRemoveList = Arrays.asList("bbc", "ks2", "read", "phet", "bitesize", "maths");
    Set stringsToRemoveSet = new HashSet<String>(stringsToRemoveList);

    while (true) {
        title = StringUtils.trim(title);
        title = StringUtils.removeStart(title, ",");
        title = StringUtils.removeStart(title, ".");
        title = StringUtils.removeStart(title, "-");
        title = StringUtils.removeStart(title, ":");
        title = StringUtils.removeEnd(title, ",");
        title = StringUtils.removeEnd(title, ".");
        title = StringUtils.removeEnd(title, "-");
        title = StringUtils.removeEnd(title, ":");
        title = StringUtils.trim(title);

        String[] words = StringUtils.split(title, ": ");
        if (words.length > 0 && stringsToRemoveSet.contains(words[0].toLowerCase())) {
            title = StringUtils.removeStartIgnoreCase(title, words[0]);
        } else if (words.length > 0 && stringsToRemoveSet.contains(words[words.length - 1].toLowerCase())) {
            title = StringUtils.removeEndIgnoreCase(title, words[words.length - 1]);
        } else {// ww  w .  j a  va 2 s  . co m
            break;
        }
    }
    return title;
}

From source file:org.eurekastreams.server.service.servlets.RequestUriToThemeUuidTransformer.java

/**
 * Parse theme uuid from request uri. Expecting to handle format of
 * /blah/whatever/somethemeversion<UUID_SEPARATOR>themuuid<FILE_EXTENSION>
 * //  www  . j av  a 2 s.c  o  m
 * @param inTransformType
 *            Request uri.
 * @return lower case theme uuid from request uri.
 */
@Override
public String transform(final String inTransformType) {
    return inTransformType == null ? null
            : StringUtils.removeEndIgnoreCase(StringUtils.substringAfterLast(inTransformType, uuidSeparator),
                    fileExtension).toLowerCase();
}

From source file:org.kuali.student.enrollment.class2.acal.dto.TimeSetWrapper.java

protected String formatStartDateUI(Date startDate) {
    if (startDate != null) {
        if (!isAllDay()) {
            String formattedDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(startDate);
            return StringUtils.removeEndIgnoreCase(formattedDate, "12:00 am");
        } else {/* w w w.  j  av  a2s .com*/
            return DateFormatters.MONTH_DAY_YEAR_DATE_FORMATTER.format(startDate);
        }
    } else {
        return StringUtils.EMPTY;
    }

}

From source file:org.kuali.student.enrollment.class2.acal.dto.TimeSetWrapper.java

protected String formatEndDateUI(Date endDate) {
    if (endDate != null) {
        if (!isAllDay()) {
            String formattedEndDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(endDate);
            String formattedStartDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(startDate);
            String strippedDate = StringUtils.removeStart(formattedEndDate,
                    StringUtils.substringBefore(formattedStartDate, " "));
            return StringUtils.removeEndIgnoreCase(strippedDate, "11:59 pm");
        } else {/* ww  w  .  ja va 2 s .c o  m*/
            if (isDateRange()) {
                return DateFormatters.MONTH_DAY_YEAR_DATE_FORMATTER.format(endDate);
            } else {
                return StringUtils.EMPTY;
            }
        }
    } else {
        return StringUtils.EMPTY;
    }

}

From source file:org.pentaho.di.job.entries.publish.DatasourcePublishService.java

protected String checkDswId(String modelName) {
    if (!modelName.endsWith(METADATA_EXTENSION)) {
        if (StringUtils.endsWithIgnoreCase(modelName, METADATA_EXTENSION)) {
            modelName = StringUtils.removeEndIgnoreCase(modelName, METADATA_EXTENSION);
        }/*from  w ww. j  a v a  2 s .c o  m*/
        modelName += METADATA_EXTENSION;
    }
    return modelName;
}

From source file:org.sonar.plugins.findbugs.FindbugsAntConverter.java

/**
 * Convert the exclusion ant pattern to a java regexp accepted by findbugs
 * exclusion file/* w ww. j av  a2  s  .  c  o m*/
 *
 * @param exclusion ant pattern to convert
 * @return Exclusion pattern for findbugs
 */
public static String antToJavaRegexpConvertor(String exclusion) {
    StringBuilder builder = new StringBuilder("~");
    int offset = 0;
    // First **/ or */ is optional
    if (exclusion.startsWith("**/")) {
        builder.append("(.*\\.)?");
        offset += 3;
    } else if (exclusion.startsWith("*/")) {
        builder.append("([^\\\\^\\s]*\\.)?");
        offset += 2;
    }
    for (String suffix : Java.SUFFIXES) {
        exclusion = StringUtils.removeEndIgnoreCase(exclusion, "." + suffix);
    }

    char[] array = exclusion.toCharArray();
    for (int i = offset; i < array.length; i++) {
        char c = array[i];
        if (c == '?') {
            builder.append('.');
        } else if (c == '*') {
            if (i + 1 < array.length && array[i + 1] == '*') {
                builder.append(".*");
                i++;
            } else {
                builder.append("[^\\\\^\\s]*");
            }
        } else if (c == '/') {
            builder.append("\\.");
        } else {
            builder.append(c);
        }
    }
    return builder.toString();
}

From source file:org.splevo.ui.commons.util.WorkspaceUtil.java

/**
 * Constructs an absolute path based on a given project relative path. The project's path is
 * determined by the given splevoProject. The result is a portable string, so you have to
 * convert it before showing it to the user. Anyway, the output is just fine for initializing a
 * File object.//w ww  . j  av  a  2 s. c  om
 * 
 * @param projectRelativePath
 *            The path relative to the SPLevo project given as another parameter.
 * @param splevoProject
 *            The SPLevo project defining the project.
 * @return The absolute path to the file as portable string.
 */
public static String getAbsoluteFromProjectRelativePath(String projectRelativePath,
        SPLevoProject splevoProject) {
    String workspaceRelativePath = String.format("%s%s%s",
            StringUtils.removeEndIgnoreCase(splevoProject.getWorkspace(), "/"),
            projectRelativePath.startsWith("/") ? "" : "/", projectRelativePath);

    return getAbsoluteFromWorkspaceRelativePath(workspaceRelativePath);
}

From source file:org.wisdom.raml.visitor.RamlControllerVisitor.java

/**
 * A method normalizing "resource" path. In RAML resource path must neither be empty ("/" is used in this case),
 * not ends with "/" (as all uri must start with "/").
 *
 * @param uri the uri to normalized//from w w  w  .j  a  v  a2s  . c  o  m
 * @return the normalized path
 */
private String normalizeParentPath(String uri) {
    String relativeUri = extractRelativeUrl(uri, null);
    if (relativeUri.endsWith("/") && relativeUri.length() != 1) {
        relativeUri = StringUtils.removeEndIgnoreCase(relativeUri, "/");
    }
    return relativeUri;
}