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

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

Introduction

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

Prototype

public static String removeEndIgnoreCase(final String str, final 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.

A null source string will return null .

Usage

From source file:eu.usrv.amdiforge.server.GraveAdminCommand.java

private static String stripFilename(String name) {
    return StringUtils.removeEndIgnoreCase(StringUtils.removeStartIgnoreCase(name, PREFIX), ".dat");
}

From source file:de.jcup.egradle.codeassist.RelevantCodeCutter.java

private String getRightText(String code, int offset) {
    char[] chars = code.toCharArray();
    if (chars.length <= offset) {
        return StringUtils.EMPTY;
    }//  w w w .j  a va  2s . c om
    StringBuilder sb = new StringBuilder();
    for (int i = offset; i < chars.length; i++) {
        char c = chars[i];
        if (isDelimiter(c)) {
            break;
        }
        sb.append(c);
    }
    String data = StringUtils.removeEndIgnoreCase(sb.toString(), "\r");
    return data;
}

From source file:com.nesscomputing.velocity.VelocityGuiceModule.java

protected void walk(Set<String> foundTemplates, final String prefix, FileObject root)
        throws FileSystemException, URISyntaxException {
    List<FileObject> foundFiles = Lists.newArrayList();
    root.findFiles(new MacroFileSelector(), true, foundFiles);

    for (FileObject file : foundFiles) {
        String templateName = StringUtils.removeEndIgnoreCase(root.getName().getRelativeName(file.getName()),
                ".vm");
        String bindName = prefix + "." + templateName;

        if (!foundTemplates.add(bindName)) {
            continue;
        }//from   w  w w .j a  v a 2s .c o m

        UriTemplateProvider provider = new UriTemplateProvider(file.getURL().toURI());
        bind(Template.class).annotatedWith(Names.named(bindName)).toProvider(provider).in(Scopes.SINGLETON);
    }
}

From source file:com.erudika.para.rest.Signer.java

private Request<?> buildAWSRequest(HttpServletRequest req, Set<String> headersUsed) {
    Map<String, String> headers = new HashMap<String, String>();
    for (Enumeration<String> e = req.getHeaderNames(); e.hasMoreElements();) {
        String head = e.nextElement().toLowerCase();
        if (headersUsed.contains(head)) {
            headers.put(head, req.getHeader(head));
        }/*from   w w w.j  a  v a 2  s.  c o m*/
    }

    Map<String, String> params = new HashMap<String, String>();
    for (Map.Entry<String, String[]> param : req.getParameterMap().entrySet()) {
        params.put(param.getKey(), param.getValue()[0]);
    }

    String path = req.getRequestURI();
    String endpoint = StringUtils.removeEndIgnoreCase(req.getRequestURL().toString(), path);
    String httpMethod = req.getMethod();
    InputStream entity;
    try {
        entity = new BufferedInputStream(req.getInputStream());
        if (entity.available() <= 0) {
            entity = null;
        }
    } catch (IOException ex) {
        logger.error(null, ex);
        entity = null;
    }

    return buildAWSRequest(httpMethod, endpoint, path, headers, params, entity);
}

From source file:com.iorga.iraj.servlet.AgglomeratorServlet.java

private void parseResource(final ServletConfig config, final String path)
        throws IOException, URISyntaxException {
    //TODO catch the modifications on the path itself
    final URL pathUrl = config.getServletContext().getResource(path);
    long lastModified = pathUrl.openConnection().getLastModified();
    final InputStream targetIS = pathUrl.openStream();
    final Document document = Jsoup.parse(targetIS, "UTF-8", "");
    final Elements elements = document.getElementsByAttribute(ATTRIBUTE_NAME);
    for (final Element element : elements) {
        // each element which defines iraj-agglomerate
        // retrieve the suffix
        final String suffix = element.attr(ATTRIBUTE_NAME);
        final String urlAttribute = element.attr(URL_ATTRIBUTE_ATTRIBUTE_NAME);
        String src = StringUtils.removeEndIgnoreCase(element.attr(urlAttribute), suffix);
        String prefix = "";
        if (!src.startsWith("/")) {
            // this is not an absolute file, let's add the prefix from the given path
            prefix = StringUtils.substringBeforeLast(path, "/") + "/";
            src = prefix + src;/*from   w  ww.  ja v a 2s.com*/
        }
        // searching all scripts inside the folder defined by src attribute
        lastModified = searchAndAppendAfter(config, element, src, prefix, suffix, urlAttribute, lastModified);
        // finally remove it
        element.remove();
    }

    caches.put(path, new ParsedResourceCacheEntry(path, document, lastModified));
}

From source file:architecture.ee.web.community.spring.controller.DisplayController.java

protected String getFreemarkerView(String view, String defaultView) {
    String viewToUse = StringUtils.defaultString(view, defaultView);
    if (StringUtils.endsWithAny(viewToUse, "ftl")) {
        viewToUse = StringUtils.removeEndIgnoreCase(viewToUse, ".ftl");
    }//  w w  w . ja v a 2  s . c o  m
    return viewToUse;
}

From source file:com.erudika.para.utils.Utils.java

/**
 * Quick and dirty singular to plural conversion.
 * @param singul a word//from   w w w  . j a v  a  2 s  .c  om
 * @return a guess of its plural form
 */
public static String singularToPlural(String singul) {
    return StringUtils.isBlank(singul) ? singul
            : (singul.endsWith("s") ? singul + "es"
                    : (singul.endsWith("y") ? StringUtils.removeEndIgnoreCase(singul, "y") + "ies"
                            : singul + "s"));
}

From source file:com.thoughtworks.go.util.SystemEnvironment.java

private String trimMegaFromSize(String sizeInMega) {
    return StringUtils.removeEndIgnoreCase(sizeInMega, "M");
}

From source file:com.google.dart.java2dart.SyntaxTranslator.java

@Override
public boolean visit(org.eclipse.jdt.core.dom.NumberLiteral node) {
    String token = node.getToken();
    if (token.contains(".") || !StringUtils.startsWithIgnoreCase(token, "0x")
            && (StringUtils.endsWithIgnoreCase(token, "F") || StringUtils.endsWithIgnoreCase(token, "D"))) {
        token = StringUtils.removeEndIgnoreCase(token, "F");
        token = StringUtils.removeEndIgnoreCase(token, "D");
        if (!token.contains(".")) {
            token += ".0";
        }//  w w w.  j a v a 2s. c  om
        return done(new DoubleLiteral(token(TokenType.DOUBLE, token), 0));
    } else {
        token = StringUtils.removeEndIgnoreCase(token, "L");
        return done(new IntegerLiteral(token(TokenType.INT, token), BigInteger.valueOf(0)));
    }
}

From source file:com.xpn.xwiki.store.XWikiHibernateStore.java

/**
 * @param whereSQL the SQL where clause//from  ww w . ja v a  2s . c  o m
 * @return the list of columns to return in the select clause as a string starting with ", " if there are columns or
 *         an empty string otherwise. The returned columns are extracted from the where clause. One reason for doing
 *         so is because HSQLDB only support SELECT DISTINCT SQL statements where the columns operated on are
 *         returned from the query.
 */
protected String getColumnsForSelectStatement(String whereSQL) {
    StringBuffer columns = new StringBuffer();

    int orderByPos = whereSQL.toLowerCase().indexOf("order by");
    if (orderByPos >= 0) {
        String orderByStatement = whereSQL.substring(orderByPos + "order by".length() + 1);
        StringTokenizer tokenizer = new StringTokenizer(orderByStatement, ",");
        while (tokenizer.hasMoreTokens()) {
            String column = tokenizer.nextToken().trim();
            // Remove "desc" or "asc" from the column found
            column = StringUtils.removeEndIgnoreCase(column, " desc");
            column = StringUtils.removeEndIgnoreCase(column, " asc");
            columns.append(", ").append(column.trim());
        }
    }

    return columns.toString();
}