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

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

Introduction

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

Prototype

public static String removeEnd(String str, String remove) 

Source Link

Document

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

Usage

From source file:com.vecna.taglib.processor.JspTagFileProcessor.java

/**
 * Scan a directory with tag files and add info about them to a taglib model
 * @param root webapp root directory//  ww w.j  a v  a 2s  .c o m
 * @param tagDir tag directory relative to the webapp root
 * @param taglib taglib model object
 */
public void addLocalMetadata(String root, String tagDir, JspTaglibModel taglib) {
    File dir = new File(root + File.separator + tagDir);
    if (dir.exists() && dir.isDirectory()) {
        String[] files = dir.list();
        for (String file : files) {
            if (file.endsWith(".tag")) {
                JspTagFileModel tagFile = new JspTagFileModel();
                tagFile.name = StringUtils.removeEnd(file, ".tag");
                tagFile.path = tagDir + File.separator + file;
                taglib.tagFiles.add(tagFile);
            }
        }
    }
}

From source file:ddf.catalog.cache.solr.impl.CacheQueryFactory.java

QueryRequest getQueryRequestWithSourcesFilter(QueryRequest input) {
    QueryRequest queryWithSources = input;
    if (input.getSourceIds() != null) {
        List<Filter> sourceFilters = new ArrayList<>();
        for (String sourceId : input.getSourceIds()) {
            sourceFilters.add(builder/*from  w w  w  . j  av  a 2s .c o  m*/
                    .attribute(StringUtils.removeEnd(SolrCache.METACARD_SOURCE_NAME, SchemaFields.TEXT_SUFFIX))
                    .is().equalTo().text(sourceId));
        }
        QueryImpl sourceQuery = new QueryImpl(builder.allOf(input.getQuery(), builder.anyOf(sourceFilters)));
        sourceQuery.setPageSize(input.getQuery().getPageSize());
        sourceQuery.setStartIndex(input.getQuery().getStartIndex());
        sourceQuery.setSortBy(input.getQuery().getSortBy());
        sourceQuery.setTimeoutMillis(input.getQuery().getTimeoutMillis());
        queryWithSources = new QueryRequestImpl(sourceQuery, input.isEnterprise(), input.getSourceIds(),
                input.getProperties());
    }
    return queryWithSources;
}

From source file:info.magnolia.cms.gui.controlx.search.SelectSearchControlDefinition.java

public String getJsField() {

    List pairs = new ArrayList();
    for (MapIterator iter = this.getOptions().orderedMapIterator(); iter.hasNext();) {
        iter.next();//  w  ww. j av  a2s .  com
        String key = (String) iter.getKey();
        String value = (String) iter.getValue();
        pairs.add("'" + key + "': '" + value + "'");
    }

    String str = super.getJsField();
    str = StringUtils.removeEnd(str, "}");
    str += ",options: {";
    str += StringUtils.join(pairs.iterator(), ",");
    str += "}}";
    return str;
}

From source file:com.intuit.tank.rest.RestUrlBuilder.java

/**
 * Builds the url with the specified methodName and parameter.
 * //from  w  w w.j  a va2s.c om
 * @param methodName
 *            the methodName
 * @param parameter
 *            the parameter value
 * @return the url.
 */
@Nonnull
public String buildUrl(@Nullable String methodName, @Nullable Object... parameters) {
    StringBuilder sb = new StringBuilder(baseUrl);
    if (methodName != null) {
        if (!methodName.startsWith("/")) {
            sb.append('/');
        }
        sb.append(StringUtils.removeEnd(methodName, "/"));

    }
    if (parameters != null) {
        for (Object parameter : parameters) {
            if (parameter != null) {
                String s = parameter.toString();
                if (!s.startsWith("/")) {
                    sb.append('/');
                }
                sb.append(s);
            }
        }
    }
    return sb.toString();
}

From source file:cec.easyshop.storefront.controllers.integration.BaseIntegrationController.java

protected void initializeSiteFromRequest(final HttpServletRequest httpRequest) {

    final String queryString = httpRequest.getQueryString();
    final String currentRequestURL = httpRequest.getRequestURL().toString();
    final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/")
            + (StringUtils.isBlank(queryString) ? "" : "?" + queryString);

    try {//  ww w. ja  v  a2s.  c o  m

        final URL currentURL = new URL(absoluteURL);
        final CMSSiteModel cmsSiteModel = cmsSiteService.getSiteForURL(currentURL);
        if (cmsSiteModel != null) {
            baseSiteService.setCurrentBaseSite(cmsSiteModel, true);
        }
    } catch (final MalformedURLException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Cannot find CMSSite associated with current URL ( " + absoluteURL
                    + " - check whether this is correct URL) !");
        }
    } catch (final CMSItemNotFoundException e) {
        LOG.warn("Cannot find CMSSite associated with current URL (" + absoluteURL + ")!");
        if (LOG.isDebugEnabled()) {
            LOG.debug(e);
        }
    }
}

From source file:com.hangum.tadpole.rdb.core.dialog.export.sqltoapplication.application.SQLToRealGridConvert.java

/**
 * sql to string// ww w . ja  va 2 s.  c  o m
 * 
 * @param name
 * @param sql
 * @return
 */
public static String sqlToString(UserDBDAO userDB, String name, String sql) {
    String retHtml = "";
    try {
        String STR_TEMPLATE = IOUtils.toString(SQLToRealGridConvert.class.getResource("realgrid.js.template"));

        QueryExecuteResultDTO queryResult = QueryUtils.executeQuery(userDB, sql, 0, 4);
        Map<Integer, String> columnLabel = queryResult.getColumnLabelName();
        Map<Integer, Integer> columnType = queryResult.getColumnType();

        String strField = "";
        StringBuffer sbField = new StringBuffer();
        for (int i = 0; i < columnLabel.size(); i++) {
            String strColumnLabel = columnLabel.get(i);
            boolean isNumber = RDBTypeToJavaTypeUtils.isNumberType(columnType.get(i));
            sbField.append(String.format(GROUP_TEMPLATE, strColumnLabel, isNumber ? "number" : "text"));
        }
        strField = StringUtils.removeEnd(sbField.toString(), ",");

        String strColumn = "";
        StringBuffer sbColumn = new StringBuffer();
        for (int i = 0; i < columnLabel.size(); i++) {
            String strColumnLabel = columnLabel.get(i);
            sbColumn.append(String.format(GROUP_DATA_TEMPLATE, strColumnLabel, strColumnLabel));
        }
        strColumn = StringUtils.removeEnd(sbColumn.toString(), ",");

        retHtml = StringUtils.replaceOnce(STR_TEMPLATE, "_TDB_TEMPLATE_FIELD_", strField);
        retHtml = StringUtils.replaceOnce(retHtml, "_TDB_TEMPLATE_COLUMN_", strColumn);
    } catch (Exception e) {
        logger.error("SQL template exception", e);
    }

    return retHtml;
}

From source file:com.evolveum.midpoint.model.impl.dataModel.dot.DotRepositoryDataItem.java

@Override
public String getNodeLabel() {
    String entity = StringUtils.removeEnd(dataItem.getTypeName().getLocalPart(), "Type");
    String pathString = dataItem.getItemPath().toString();
    final String EXT = "extension/";
    if (pathString.startsWith(EXT)) {
        entity += " extension";
        pathString = pathString.substring(EXT.length());
    }/*  w w w . j  av  a 2 s .c om*/
    return entity + "&#10;" + pathString;
}

From source file:com.ewcms.content.resource.web.ResourceAction.java

public String input() {
    context = ServletActionContext.getRequest().getContextPath();
    context = StringUtils.removeEnd(context, "/");
    Resource.Type resType = Resource.Type.valueOf(StringUtils.upperCase(type));
    fileDesc = resType.getFileDesc();//from  ww w. j a v a  2s.com
    fileExt = resType.getFileExt();
    return Action.SUCCESS;
}

From source file:ips1ap101.web.AbstractPageBean1.java

@Override
public String getManagedBeanName() {
    String path = getRequestPathInfo();
    String substring = StringUtils.removeEnd(StringUtils.removeStart(path, "/"), requestPathSuffix());
    String managedBeanName = substring.replace('/', '$');
    return managedBeanName;
}

From source file:com.aqnote.shared.cryptology.cert.tool.X509CertTool.java

private static byte[] getCertEncoded(String base64CrtFile) {
    if (StringUtils.isEmpty(base64CrtFile)) {
        return null;
    }/*from   w  w w .  j  a  v  a  2 s.  c om*/

    String tmpBase64CrtFile = base64CrtFile;
    String headLine = BEGIN_CERT + lineSeparator;
    if (base64CrtFile.startsWith(headLine)) {
        tmpBase64CrtFile = StringUtils.removeStart(base64CrtFile, headLine);
    }
    if (tmpBase64CrtFile.endsWith(END_CERT)) {
        tmpBase64CrtFile = StringUtils.removeEnd(tmpBase64CrtFile, END_CERT);
    }

    return Base64.decodeBase64(tmpBase64CrtFile);
}